if conditions vs include (v2)

Revision 2 of this benchmark created on


Setup

function a(status) {
  switch (status) {
  case 'pack':
  case 'sweater':
  case 'macabre':
  case 'record':
  case 'grain':
  case 'seashore':
  case 'cynical':
  case 'ticket':
  case 'hapless':
  case 'number':
  case 'colossal':
  case 'curious':
  case 'doubt':
  case 'inject':
  case 'erratic':
  case 'courageous':
  case 'drip':
  case 'mundane':
  case 'dark':
  case 'nutty':
  case 'trust':
  case 'obscene':
  case 'decorate':
  case 'verdant':
  case 'needle':
  case 'utopian':
  case 'cake':
  case 'daughter':
  case 'mighty':
  case 'frame':
  case 'steep':
  case 'fill':
  case 'aboard':
  case 'bright':
  case 'coordinated':
  case 'command':
  case 'taboo':
  case 'adjustment':
  case 'pray':
  case 'telephone':
  case 'flow':
  case 'use':
  case 'stop':
  case 'disarm':
  case 'press':
  case 'statement':
  case 'nod':
  case 'icy':
  case 'gray':
  case 'puncture':
  case 'north':
  case 'unequaled':
  case 'scared':
  case 'spoil':
  case 'scattered':
  case 'letter':
  case 'eggs':
  case 'skirt':
  case 'protect':
  case 'belligerent':
  case 'marvelous':
  case 'magical':
  case 'offbeat':
  case 'clammy':
  case 'fearful':
  case 'direction':
  case 'parsimonious':
  case 'childlike':
  case 'flaky':
  case 'disastrous':
  case 'lock':
  case 'nose':
  case 'bells':
  case 'scatter':
  case 'jump':
  case 'button':
  case 'brawny':
  case 'crush':
  case 'skinny':
  case 'haunt':
  case 'box':
  case 'ear':
  case 'ugly':
  case 'slimy':
  case 'snakes':
  case 'mother':
  case 'special':
  case 'vessel':
  case 'unable':
  case 'hungry':
  case 'vacuous':
  case 'mouth':
  case 'undress':
  case 'false':
  case 'fertile':
  case 'free':
  case 'event':
  case 'pass':
  case 'delightful':
  case 'highfalutin':
    return true
  }
}
function b(status) {
  if (
    status == 'pack' ||
    status == 'sweater' ||
    status == 'macabre' ||
    status == 'record' ||
    status == 'grain' ||
    status == 'seashore' ||
    status == 'cynical' ||
    status == 'ticket' ||
    status == 'hapless' ||
    status == 'number' ||
    status == 'colossal' ||
    status == 'curious' ||
    status == 'doubt' ||
    status == 'inject' ||
    status == 'erratic' ||
    status == 'courageous' ||
    status == 'drip' ||
    status == 'mundane' ||
    status == 'dark' ||
    status == 'nutty' ||
    status == 'trust' ||
    status == 'obscene' ||
    status == 'decorate' ||
    status == 'verdant' ||
    status == 'needle' ||
    status == 'utopian' ||
    status == 'cake' ||
    status == 'daughter' ||
    status == 'mighty' ||
    status == 'frame' ||
    status == 'steep' ||
    status == 'fill' ||
    status == 'aboard' ||
    status == 'bright' ||
    status == 'coordinated' ||
    status == 'command' ||
    status == 'taboo' ||
    status == 'adjustment' ||
    status == 'pray' ||
    status == 'telephone' ||
    status == 'flow' ||
    status == 'use' ||
    status == 'stop' ||
    status == 'disarm' ||
    status == 'press' ||
    status == 'statement' ||
    status == 'nod' ||
    status == 'icy' ||
    status == 'gray' ||
    status == 'puncture' ||
    status == 'north' ||
    status == 'unequaled' ||
    status == 'scared' ||
    status == 'spoil' ||
    status == 'scattered' ||
    status == 'letter' ||
    status == 'eggs' ||
    status == 'skirt' ||
    status == 'protect' ||
    status == 'belligerent' ||
    status == 'marvelous' ||
    status == 'magical' ||
    status == 'offbeat' ||
    status == 'clammy' ||
    status == 'fearful' ||
    status == 'direction' ||
    status == 'parsimonious' ||
    status == 'childlike' ||
    status == 'flaky' ||
    status == 'disastrous' ||
    status == 'lock' ||
    status == 'nose' ||
    status == 'bells' ||
    status == 'scatter' ||
    status == 'jump' ||
    status == 'button' ||
    status == 'brawny' ||
    status == 'crush' ||
    status == 'skinny' ||
    status == 'haunt' ||
    status == 'box' ||
    status == 'ear' ||
    status == 'ugly' ||
    status == 'slimy' ||
    status == 'snakes' ||
    status == 'mother' ||
    status == 'special' ||
    status == 'vessel' ||
    status == 'unable' ||
    status == 'hungry' ||
    status == 'vacuous' ||
    status == 'mouth' ||
    status == 'undress' ||
    status == 'false' ||
    status == 'fertile' ||
    status == 'free' ||
    status == 'event' ||
    status == 'pass' ||
    status == 'delightful' ||
    status == 'highfalutin'
  ) {
    return true
  }
}
function c(status) {
  if (['pack', 'sweater', 'macabre', 'record', 'grain', 'seashore', 'cynical', 'ticket', 'hapless', 'number', 'colossal', 'curious', 'doubt', 'inject', 'erratic', 'courageous', 'drip', 'mundane', 'dark', 'nutty', 'trust', 'obscene', 'decorate', 'verdant', 'needle', 'utopian', 'cake', 'daughter', 'mighty', 'frame', 'steep', 'fill', 'aboard', 'bright', 'coordinated', 'command', 'taboo', 'adjustment', 'pray', 'telephone', 'flow', 'use', 'stop', 'disarm', 'press', 'statement', 'nod', 'icy', 'gray', 'puncture', 'north', 'unequaled', 'scared', 'spoil', 'scattered', 'letter', 'eggs', 'skirt', 'protect', 'belligerent', 'marvelous', 'magical', 'offbeat', 'clammy', 'fearful', 'direction', 'parsimonious', 'childlike', 'flaky', 'disastrous', 'lock', 'nose', 'bells', 'scatter', 'jump', 'button', 'brawny', 'crush', 'skinny', 'haunt', 'box', 'ear', 'ugly', 'slimy', 'snakes', 'mother', 'special', 'vessel', 'unable', 'hungry', 'vacuous', 'mouth', 'undress', 'false', 'fertile', 'free', 'event', 'pass', 'delightful', 'highfalutin'].includes(status)) {
    return true
  }
}
let x = ['pack', 'sweater', 'macabre', 'record', 'grain', 'seashore', 'cynical', 'ticket', 'hapless', 'number', 'colossal', 'curious', 'doubt', 'inject', 'erratic', 'courageous', 'drip', 'mundane', 'dark', 'nutty', 'trust', 'obscene', 'decorate', 'verdant', 'needle', 'utopian', 'cake', 'daughter', 'mighty', 'frame', 'steep', 'fill', 'aboard', 'bright', 'coordinated', 'command', 'taboo', 'adjustment', 'pray', 'telephone', 'flow', 'use', 'stop', 'disarm', 'press', 'statement', 'nod', 'icy', 'gray', 'puncture', 'north', 'unequaled', 'scared', 'spoil', 'scattered', 'letter', 'eggs', 'skirt', 'protect', 'belligerent', 'marvelous', 'magical', 'offbeat', 'clammy', 'fearful', 'direction', 'parsimonious', 'childlike', 'flaky', 'disastrous', 'lock', 'nose', 'bells', 'scatter', 'jump', 'button', 'brawny', 'crush', 'skinny', 'haunt', 'box', 'ear', 'ugly', 'slimy', 'snakes', 'mother', 'special', 'vessel', 'unable', 'hungry', 'vacuous', 'mouth', 'undress', 'false', 'fertile', 'free', 'event', 'pass', 'delightful', 'highfalutin']
function d(status) {
  if (x.includes(status)) {
    return true
  }
}
function e(status) {
  if (/^pack$|^sweater$|^macabre$|^record$|^grain$|^seashore$|^cynical$|^ticket$|^hapless$|^number$|^colossal$|^curious$|^doubt$|^inject$|^erratic$|^courageous$|^drip$|^mundane$|^dark$|^nutty$|^trust$|^obscene$|^decorate$|^verdant$|^needle$|^utopian$|^cake$|^daughter$|^mighty$|^frame$|^steep$|^fill$|^aboard$|^bright$|^coordinated$|^command$|^taboo$|^adjustment$|^pray$|^telephone$|^flow$|^use$|^stop$|^disarm$|^press$|^statement$|^nod$|^icy$|^gray$|^puncture$|^north$|^unequaled$|^scared$|^spoil$|^scattered$|^letter$|^eggs$|^skirt$|^protect$|^belligerent$|^marvelous$|^magical$|^offbeat$|^clammy$|^fearful$|^direction$|^parsimonious$|^childlike$|^flaky$|^disastrous$|^lock$|^nose$|^bells$|^scatter$|^jump$|^button$|^brawny$|^crush$|^skinny$|^haunt$|^box$|^ear$|^ugly$|^slimy$|^snakes$|^mother$|^special$|^vessel$|^unable$|^hungry$|^vacuous$|^mouth$|^undress$|^false$|^fertile$|^free$|^event$|^pass$|^delightful$|^highfalutin$/.test(status)) {
  	return true
  }
}

Test runner

Ready to run.

Testing in
TestOps/sec
a - switch
a('pack'); a('sweater'); a('macabre'); a('record'); a('grain'); a('seashore'); a('cynical'); a('ticket'); a('hapless'); a('number'); a('colossal'); a('curious'); a('doubt'); a('inject'); a('erratic'); a('courageous'); a('drip'); a('mundane'); a('dark'); a('nutty'); a('trust'); a('obscene'); a('decorate'); a('verdant'); a('needle'); a('utopian'); a('cake'); a('daughter'); a('mighty'); a('frame'); a('steep'); a('fill'); a('aboard'); a('bright'); a('coordinated'); a('command'); a('taboo'); a('adjustment'); a('pray'); a('telephone'); a('flow'); a('use'); a('stop'); a('disarm'); a('press'); a('statement'); a('nod'); a('icy'); a('gray'); a('puncture'); a('north'); a('unequaled'); a('scared'); a('spoil'); a('scattered'); a('letter'); a('eggs'); a('skirt'); a('protect'); a('belligerent'); a('marvelous'); a('magical'); a('offbeat'); a('clammy'); a('fearful'); a('direction'); a('parsimonious'); a('childlike'); a('flaky'); a('disastrous'); a('lock'); a('nose'); a('bells'); a('scatter'); a('jump'); a('button'); a('brawny'); a('crush'); a('skinny'); a('haunt'); a('box'); a('ear'); a('ugly'); a('slimy'); a('snakes'); a('mother'); a('special'); a('vessel'); a('unable'); a('hungry'); a('vacuous'); a('mouth'); a('undress'); a('false'); a('fertile'); a('free'); a('event'); a('pass'); a('delightful'); a('highfalutin');
ready
b - ||
b('pack'); b('sweater'); b('macabre'); b('record'); b('grain'); b('seashore'); b('cynical'); b('ticket'); b('hapless'); b('number'); b('colossal'); b('curious'); b('doubt'); b('inject'); b('erratic'); b('courageous'); b('drip'); b('mundane'); b('dark'); b('nutty'); b('trust'); b('obscene'); b('decorate'); b('verdant'); b('needle'); b('utopian'); b('cake'); b('daughter'); b('mighty'); b('frame'); b('steep'); b('fill'); b('aboard'); b('bright'); b('coordinated'); b('command'); b('taboo'); b('adjustment'); b('pray'); b('telephone'); b('flow'); b('use'); b('stop'); b('disarm'); b('press'); b('statement'); b('nod'); b('icy'); b('gray'); b('puncture'); b('north'); b('unequaled'); b('scared'); b('spoil'); b('scattered'); b('letter'); b('eggs'); b('skirt'); b('protect'); b('belligerent'); b('marvelous'); b('magical'); b('offbeat'); b('clammy'); b('fearful'); b('direction'); b('parsimonious'); b('childlike'); b('flaky'); b('disastrous'); b('lock'); b('nose'); b('bells'); b('scatter'); b('jump'); b('button'); b('brawny'); b('crush'); b('skinny'); b('haunt'); b('box'); b('ear'); b('ugly'); b('slimy'); b('snakes'); b('mother'); b('special'); b('vessel'); b('unable'); b('hungry'); b('vacuous'); b('mouth'); b('undress'); b('false'); b('fertile'); b('free'); b('event'); b('pass'); b('delightful'); b('highfalutin');
ready
c - array.includes
c('pack'); c('sweater'); c('macabre'); c('record'); c('grain'); c('seashore'); c('cynical'); c('ticket'); c('hapless'); c('number'); c('colossal'); c('curious'); c('doubt'); c('inject'); c('erratic'); c('courageous'); c('drip'); c('mundane'); c('dark'); c('nutty'); c('trust'); c('obscene'); c('decorate'); c('verdant'); c('needle'); c('utopian'); c('cake'); c('daughter'); c('mighty'); c('frame'); c('steep'); c('fill'); c('aboard'); c('bright'); c('coordinated'); c('command'); c('taboo'); c('adjustment'); c('pray'); c('telephone'); c('flow'); c('use'); c('stop'); c('disarm'); c('press'); c('statement'); c('nod'); c('icy'); c('gray'); c('puncture'); c('north'); c('unequaled'); c('scared'); c('spoil'); c('scattered'); c('letter'); c('eggs'); c('skirt'); c('protect'); c('belligerent'); c('marvelous'); c('magical'); c('offbeat'); c('clammy'); c('fearful'); c('direction'); c('parsimonious'); c('childlike'); c('flaky'); c('disastrous'); c('lock'); c('nose'); c('bells'); c('scatter'); c('jump'); c('button'); c('brawny'); c('crush'); c('skinny'); c('haunt'); c('box'); c('ear'); c('ugly'); c('slimy'); c('snakes'); c('mother'); c('special'); c('vessel'); c('unable'); c('hungry'); c('vacuous'); c('mouth'); c('undress'); c('false'); c('fertile'); c('free'); c('event'); c('pass'); c('delightful'); c('highfalutin');
ready
d - cached array.includes
d('pack'); d('sweater'); d('macabre'); d('record'); d('grain'); d('seashore'); d('cynical'); d('ticket'); d('hapless'); d('number'); d('colossal'); d('curious'); d('doubt'); d('inject'); d('erratic'); d('courageous'); d('drip'); d('mundane'); d('dark'); d('nutty'); d('trust'); d('obscene'); d('decorate'); d('verdant'); d('needle'); d('utopian'); d('cake'); d('daughter'); d('mighty'); d('frame'); d('steep'); d('fill'); d('aboard'); d('bright'); d('coordinated'); d('command'); d('taboo'); d('adjustment'); d('pray'); d('telephone'); d('flow'); d('use'); d('stop'); d('disarm'); d('press'); d('statement'); d('nod'); d('icy'); d('gray'); d('puncture'); d('north'); d('unequaled'); d('scared'); d('spoil'); d('scattered'); d('letter'); d('eggs'); d('skirt'); d('protect'); d('belligerent'); d('marvelous'); d('magical'); d('offbeat'); d('clammy'); d('fearful'); d('direction'); d('parsimonious'); d('childlike'); d('flaky'); d('disastrous'); d('lock'); d('nose'); d('bells'); d('scatter'); d('jump'); d('button'); d('brawny'); d('crush'); d('skinny'); d('haunt'); d('box'); d('ear'); d('ugly'); d('slimy'); d('snakes'); d('mother'); d('special'); d('vessel'); d('unable'); d('hungry'); d('vacuous'); d('mouth'); d('undress'); d('false'); d('fertile'); d('free'); d('event'); d('pass'); d('delightful'); d('highfalutin');
ready
e - regular expression
e('pack'); e('sweater'); e('macabre'); e('record'); e('grain'); e('seashore'); e('cynical'); e('ticket'); e('hapless'); e('number'); e('colossal'); e('curious'); e('doubt'); e('inject'); e('erratic'); e('courageous'); e('drip'); e('mundane'); e('dark'); e('nutty'); e('trust'); e('obscene'); e('decorate'); e('verdant'); e('needle'); e('utopian'); e('cake'); e('daughter'); e('mighty'); e('frame'); e('steep'); e('fill'); e('aboard'); e('bright'); e('coordinated'); e('command'); e('taboo'); e('adjustment'); e('pray'); e('telephone'); e('flow'); e('use'); e('stop'); e('disarm'); e('press'); e('statement'); e('nod'); e('icy'); e('gray'); e('puncture'); e('north'); e('unequaled'); e('scared'); e('spoil'); e('scattered'); e('letter'); e('eggs'); e('skirt'); e('protect'); e('belligerent'); e('marvelous'); e('magical'); e('offbeat'); e('clammy'); e('fearful'); e('direction'); e('parsimonious'); e('childlike'); e('flaky'); e('disastrous'); e('lock'); e('nose'); e('bells'); e('scatter'); e('jump'); e('button'); e('brawny'); e('crush'); e('skinny'); e('haunt'); e('box'); e('ear'); e('ugly'); e('slimy'); e('snakes'); e('mother'); e('special'); e('vessel'); e('unable'); e('hungry'); e('vacuous'); e('mouth'); e('undress'); e('false'); e('fertile'); e('free'); e('event'); e('pass'); e('delightful'); e('highfalutin');
ready

Revisions

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