jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
<canvas id="c"></canvas>
<script>
var SIZE = 500;
var canvas = document.getElementById('c');
canvas.style.width = SIZE + "px";
canvas.style.heigth = SIZE + "px";
function Processor(canvas) {
this.canvas = canvas;
//this.color = [1,2,3];
var ctx = canvas.getContext('2d');
ctx.width = ctx.heigth = SIZE;
this.ctx = ctx;
this.image_data = ctx.getImageData(0, 0, SIZE, SIZE);
}
_.extend(Processor.prototype, {color : [1,2,3]});
Processor.prototype.run = function() {
var pixel_pos;
var image_data = this.image_data;
var color = this.color;
for(var i=0; i < SIZE; ++i) {
for(var j=0; j < SIZE; ++j) {
pixel_pos = (j*SIZE + i) * 4;
image_data[pixel_pos + 0] = color[0];
image_data[pixel_pos + 1] = color[1];
image_data[pixel_pos + 2] = color[2];
}
}
this.ctx.putImageData(image_data, 0, 0);
}
Processor.prototype.run2 = function() {
var pixel_pos;
var image_data = this.image_data;
var color = [1,2,3];
for(var i=0; i < SIZE; ++i) {
for(var j=0; j < SIZE; ++j) {
pixel_pos = (j*SIZE + i) * 4;
image_data[pixel_pos + 0] = color[0];
image_data[pixel_pos + 1] = color[1];
image_data[pixel_pos + 2] = color[2];
}
}
this.ctx.putImageData(image_data, 0, 0);
}
var processor = new Processor(canvas);
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
this reference |
| ready |
constant reference |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.