funkystuff

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var foo = [123, 222, 3];
    var color = 123;
   
    var HUNDRED_DIVIDED_BY_255 = 0.39215686274509803;
   
    function getMax(nums) {
      var sorted = nums.sort();
      return sorted[nums.length-1];
    }
   
   
   
    function rgb2b(rgb) {
      return (rgb[0] + rgb[1] + rgb[2]) / 3 / 255 * 100 << 0;
    }
   
    function derp(rgb){
      return (rgb[0] + rgb[1] + rgb[2]) / 3 * HUNDRED_DIVIDED_BY_255 >> 0;
    }
   
    function monoChannel(c) {
      return c * HUNDRED_DIVIDED_BY_255 >> 0;
    }
   
    function b(rgb) {
      return getMax(rgb) * HUNDRED_DIVIDED_BY_255 >> 0;
    }
};
</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
getmax
b(foo);
pending…
rgb2b
rgb2b(foo);
pending…
some tuning
derp(foo);
pending…
mono
monoChannel(foo.r);
pending…
mono 2
monoChannel(color);
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