@rmurphey-foo-foo-foo
JavaScript performance comparison
Info
Testing performance of different implementations for @rmurpheys challenge for creating and array of tripled string values.
http://gist.github.com/576723
Who said JavaScript OCD?
Preparation code
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
function cubeString(str) {
return str + " " + str + " " + str;
}
</script>
<script>
// 5: given the following array, create an array that contains the contents of
// each array item repeated three times, with a space between each item. so,
// for example, if an array item is 'foo' then the new array should contain an
// array item 'foo foo foo'. (you can assume the library of your choice is
// available)
var myArray = ['foo', 'bar', 'baz'];
</script>
Preparation code output
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
for loop |
|
pending… |
ES5 - forEach |
|
pending… |
ES5 - map |
|
pending… |
jQuery.each |
|
pending… |
jQuery.map |
|
pending… |
for loop, regexp concat |
|
pending… |
regex loop/replace |
|
pending… |
regex loop/concat |
|
pending… |
while loop with cached item |
|
pending… |
for loop, string replace |
|
pending… |
WR slim loop |
|
pending… |
WR slick map |
|
pending… |
WR slick loop |
|
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. Here’s a list of current revisions for this page:
- Revision 1: published by Morgan Roderick
- Revision 2: published by Matt S
- Revision 4: published by Tim Caswell
- Revision 9: published by Alex Sexton
- Revision 11: published by Kyle Simpson
- Revision 13: published by Alex Sexton
- Revision 14: published by Alex Sexton
- Revision 17: published by Ricardo Tomasi
- Revision 18: published by António Afonso
- Revision 27: published by Alan Smithee
- Revision 29: published by Eddie Monge
- Revision 30: published by WebReflection
- Revision 31: published by bga_
- Revision 36: published
- Revision 37: published
- Revision 38: published
- Revision 39: published by sahil budhiraja
- Revision 40: published by Grant Kiely
- Revision 41: published
- Revision 42: published
0 comments