R
RobG
I was playing with shuffling routines so I browsed those at
merlyn.demon.co.uk[1]. I did a bit of work and wrote what I thought
was a much faster version. According to my tests, it's 3 to 4 times
faster in Firefox and IE and about equal in Opera, Chrome and mobile
Safari.
I put some test cases on jsperf[2] only to discover that suddenly the
peformance of the "StocktonShuffle" was greatly enhanced in all
browsers except IE. The most dramatic was Firefox, where it went from
being 4 times slower to 3 times faster. I have no idea why there
should be such huge differences. The two functions are posted on
jsperf[2], unfortunately the part that stores results is broken so no
history of tests that have been run.
Here is my local test function:
function speedTest() {
var a, b = '0123456789'.split('');
var arg, args = arguments;
var result = [];
var i, s;
var n = 10000;
for (var j=0, jLen=args.length; j<jLen; j++) {
arg = args[j]
a = b.concat();
i = n;
s = new Date();
while (i--) {
window[arg](a);
}
result.push(arg + ': ' + (new Date() - s));
}
return result;
}
alert( speedTest('allInOneShuffle','StocktonShuffle').join('<br>') );
Can anyone explain the rather large differences in peformance?
1. <URL: http://www.merlyn.demon.co.uk/js-shufl.htm#FnB >
2. <URL: http://jsperf.com/shuffle110609 >
merlyn.demon.co.uk[1]. I did a bit of work and wrote what I thought
was a much faster version. According to my tests, it's 3 to 4 times
faster in Firefox and IE and about equal in Opera, Chrome and mobile
Safari.
I put some test cases on jsperf[2] only to discover that suddenly the
peformance of the "StocktonShuffle" was greatly enhanced in all
browsers except IE. The most dramatic was Firefox, where it went from
being 4 times slower to 3 times faster. I have no idea why there
should be such huge differences. The two functions are posted on
jsperf[2], unfortunately the part that stores results is broken so no
history of tests that have been run.
Here is my local test function:
function speedTest() {
var a, b = '0123456789'.split('');
var arg, args = arguments;
var result = [];
var i, s;
var n = 10000;
for (var j=0, jLen=args.length; j<jLen; j++) {
arg = args[j]
a = b.concat();
i = n;
s = new Date();
while (i--) {
window[arg](a);
}
result.push(arg + ': ' + (new Date() - s));
}
return result;
}
alert( speedTest('allInOneShuffle','StocktonShuffle').join('<br>') );
Can anyone explain the rather large differences in peformance?
1. <URL: http://www.merlyn.demon.co.uk/js-shufl.htm#FnB >
2. <URL: http://jsperf.com/shuffle110609 >