Blending

JavaScript performance comparison

Revision 2 of this test case created

Info

inline vs function call

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    function hardLight(b, s) {
    return s == 0 ? s : Math.max(0, (255 - ((255 - b) << 8 ) / s));
    }
    var samples = 200;
    var test = new Uint8Array(samples);
    for (var i = 0; i < samples; i+=2) {
    test[i] = Math.floor(Math.random() * 255);
    test[i + 1] = Math.floor(Math.random() * 255);
    }
};
</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
function call
for (var i = 0; i < samples; i+=2) {
var s = test[i];
var b = test[i + 1];
var c = hardLight(s, b);
}
pending…
inline
for (var i = 0; i < samples; i+=2) {
var s = test[i];
var b = test[i + 1];
var c = s == 0 ? s : Math.max(0, (255 - ((255 - b) << 8 ) / s));
}
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:

0 comments

Add a comment