Google Analytics protocol check versus hardcoded string

JavaScript performance comparison

Test case created by Mathias Bynens and last updated

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var location = window.location;

};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Ternary protocol check
('https:' == location.protocol ? '//ssl' : '//www') + '.google-analytics.com/ga.js';
pending…
Hardcoded string
'http://www.google-analytics.com/ga.js';
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

2 Comments

Abdelkrim commented :

result quite astonishing!

John-David Dalton commented :

Millions of ops/sec vs. millions of ops/sec for something that is executed 1 time means there is no real world perf concern here. Also the test with a simple string literal might be being optimized away as dead code.