indexOf vs hash (v5)

Revision 5 of this benchmark created on


Setup

var a = [10, 23, 1, 5, 66, 4, 7773, 2345, 234],
          hash = {
            10: true,
            23: true,
            1: true,
            5: true,
            66: true,
            4: true,
            7773: true,
            2345: true,
            234: true
          }

Test runner

Ready to run.

Testing in
TestOps/sec
indexOf
a.indexOf(66);
ready
hash
hash[66]
ready
indeOf - first element on the array
a.indexOf(10);
ready
hash - first element on the array
hash[10];
ready
indeOf - last element on the array
a.indexOf(234);
ready
hash - last element on the array
hash[234];
ready

Revisions

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