test Join and Split

JavaScript performance comparison

Revision 8 of this test case created by Julian Dicks

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>

<span id="bigText">1,234,567,890.00.</span>
    

Preparation code output

<span id="bigText">1,234,567,890.00.</span>

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
replace
window.addEvent('domready', function() {
var target = $('bigText');
var text = target.get('html');
var replaces = {
cat : 'fish',
dog : 'mouse'
}
Object.each(replaces, function(value, key){
text = text.replace(new RegExp(key, 'g'), value);
});
target.set('html', text);
});
pending…
split join
window.addEvent('domready', function() {
var target = $('bigText');
var text = target.get('html');
var replaces = {
cat : 'fish',
dog : 'mouse'
}
Object.each(replaces, function(value, key){
text = text.split(key).join(value);
});
target.set('html', text);
});
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.

0 Comments

1,234,567,890.00.