Assignment Operators

JavaScript performance comparison

Test case created by Joshua Piccari

Info

Is it better to combine your assignment operator with your binary operator?

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = 10,
      b = 20;
};
</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
ADD
a = a + b
pending…
ADD (assign)
a += b
pending…
SUB
a = a - b
pending…
SUB (assign)
a -= b
pending…
MUL
a = a * b
pending…
MUL (assign)
a *= b
pending…
DIV
a = a / b
pending…
DIV (assign)
a /= b
pending…
AND
a = a & b
pending…
AND (assign)
a &= b
pending…
OR
a = a | b
pending…
OR (assign)
a |= b
pending…
SAR
a = a >> b
pending…
SAR (assign)
a >>= b
pending…
SHR
a = a >>> b
pending…
SHR (assign)
a >>>= b
pending…
SHL
a = a << b
pending…
SHL (assign)
a <<= b
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