Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Comma is faster than semicolon in Safari / JavaScriptCore
// ** Update:
// ** THIS ONLY AFFECTS CODE PASTED INTO WEB INSPECTOR CONSOLE
// ** ACTUAL LOADED CODE ON WEB PAGE RUNS ALMOST THE SAME WITH COMMAS OR SEMICOLONS.
// **
// Safari Version 6.0.2 (8536.26.17)
// Output:
//
// comma: 193 ms
// semicolon: 575 ms
(function() {
var t1=(new Date()).getTime();
var a=1, b=2, c=3, d=4;
for (var i = 0; i < 1000000; i++) {
a^=b,
b^=a,
b+=c,
d+=a,
a^=c,
d^=a,
c+=d
}
console.log('comma: '+((new Date()).getTime()-t1)+' ms');
t1=(new Date()).getTime();
a=1; b=2; c=3; d=4;
for (var i = 0; i < 1000000; i++) {
a^=b;
b^=a;
b+=c;
d+=a;
a^=c;
d^=a;
c+=d;
}
console.log('semicolon: '+((new Date()).getTime()-t1)+' ms');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.