which is faster i++ or i+=1 or ++i (v5)

Revision 5 of this benchmark created by Janne Enberg on


Description

Test to see if i += 1 is faster than i++ or ++i in js

Setup

var i;

Test runner

Ready to run.

Testing in
TestOps/sec
i++
for (i = 0; i< 10000; i++) {
   console.log('i++', i);
}
ready
i+=1
for (i = 0; i< 10000; i += 1) {
   console.log('i+=1', i)
};
ready
++i
for (i = 0; i< 10000; ++i) {
   console.log('++i', i)
};
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by IliaSky on
  • Revision 2: published by John Miller on
  • Revision 3: published by John Miller on
  • Revision 4: published by ryan on
  • Revision 5: published by Janne Enberg on