string concatenation for raphael strings with numbers
JavaScript performance comparison
Test case created by jrfrimme
Preparation code
<script>
Benchmark.prototype.setup = function() {
var width = 200,
offset = 10,
a = [1,2,3,4,5,6,7,8,9,10];
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
Testing in unknown unknown
| Test |
Ops/sec |
Basic String Concatenation (+=) |
var path = "", widthOffset = width - offset, i;
for (i = 0; i < a.length; i++) { path += " M " + a[i] + " " + offset + " L " + a[i] + " " + widthOffset; }
|
pending… |
Basic String Concatenation (individually) |
var path = "", widthOffset = width - offset, i;
for (i = 0; i < a.length; i++) { path = path + " M " + a[i] + " " + offset + " L " + a[i] + " " + widthOffset; }
|
pending… |
Individual += Statements |
var path = "", widthOffset = width - offset, i;
for (i = 0; i < a.length; i++) { path += " M "; path += a[i]; path += " "; path += offset; path += " L "; path += a[i]; path += " "; path += widthOffset; }
|
pending… |
Individual Statements |
var path = "", widthOffset = width - offset, i;
for (i = 0; i < a.length; i++) { path = path + " M "; path = path + a[i]; path = path + " "; path = path + offset; path = path + " L "; path = path + a[i]; path = path + " "; path = path + widthOffset; }
|
pending… |
array.join |
var path = [], widthOffset = width - offset, i;
for (i = 0; i < a.length; i++) { path.push("M"); path.push(a[i]); path.push(offset); path.push("L"); path.push(a[i]); path.push(widthOffset); }
path.join(" ")
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
Compare results of other browsers
0 comments