loop vs. lookup

Benchmark created by ratkinson on


Setup

var term = 'adsfsocks';

Test runner

Ready to run.

Testing in
TestOps/sec
loop
var hlp = ['vegan','soccer','baby-shop','cycling-and-triathlon','sporting-goods','girls-shoes','mens-jeans','pajamas','socks'];
var hlpLen = hlp.length;
while (hlpLen--) {
  if (hlp[hlpLen] == term) return;
}
ready
lookup
var hlp = {'vegan':1,'soccer':1,'baby-shop':1,'cycling-and-triathlon':1,'sporting-goods':1,'girls-shoes':1,'mens-jeans':1,'pajamas':1,'socks':1};
if (typeof(hlp[term])!='undefined') return;
ready

Revisions

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

  • Revision 1: published by ratkinson on
  • Revision 2: published by ratkinson on
  • Revision 3: published by Ian Carter on