Int8Array set vs manual concat
JavaScript performance comparison
Preparation code
<script>
Benchmark.prototype.setup = function() {
var a = new Int8Array( [ 1, 2, 3 ] );
var b = new Int8Array( [ 4, 5, 6 ] );
function concat(a,b){
var c = new Array();
for(var i = 0; i < a.length; i++){
c.push(a[i])
}
for(var i = 0; i < b.length; i++){
c.push(b[i])
}
return c;
}
function set(a,b){
var c = new Int8Array(a.length + b.length);
c.set(a);
c.set(b, a.length);
return c;
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
Set |
|
pending… |
Concat |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments