jst-7 (v2)

Revision 2 of this benchmark created by Taylor McKinney on


Setup

var codesArr = ['GB'];
  
  var codesObj = { GB: true };

Test runner

Ready to run.

Testing in
TestOps/sec
Array indexOf
// Something that is there.
codesArr.indexOf('GB');

// Something that isn't.
codesArr.indexOf('LOL');
ready
Map Lookup
// Something that is there.
codesObj['GB'];

// Something that isn't.
codesObj['LOL'];
ready
indexOf with Boolean Coercion
// Something that is there.
Boolean(codesArr.indexOf('GB'));

// Something that isn't.
Boolean(codesArr.indexOf('LOL'));
ready
Map Lookup with Boolean Coercion
// Something that is there.
Boolean(codesObj['GB']);

// Something that isn't.
Boolean(codesObj['LOL']);
ready
Map Lookup with !!-Style Boolean Coercion
// Something that is there.
!!codesArr.indexOf('GB');

// Something that isn't.
!!codesArr.indexOf('LOL');
ready
Map Lookup with !!-Style Boolean Coercion
// Something that is there.
!!codesObj['GB'];

// Something that isn't.
!!codesObj['LOL'];
ready
Object in operator
// Something that is there.
'GB' in codesObj;

// Something that isn't.
'LOL' in codesObj;
ready

Revisions

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

  • Revision 1: published by Andy on
  • Revision 2: published by Taylor McKinney on