Script Preparation code:
x
 
var cacheName ='';
componentsCfg = {};
componentsCfg.v = 1;
componentsCfg.h = 'asdf';
Tests:
  • Ternary with Concat

     
    cacheName = (componentsCfg.v && componentsCfg.h) ? 'ch-' + componentsCfg.v + '-' + componentsCfg.h : 'ch';
  • Traditional If/Else with Concat

     
    if(componentsCfg.v && componentsCfg.h) {
        cacheName = 'ch-' + componentsCfg.v + '-' + componentsCfg.h;
    } else {
        cacheName = 'ch';
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Ternary with Concat
    Traditional If/Else with Concat

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.75 Safari/537.36
Chrome 50 on Mac OS X 10.11.6
View result in a separate tab
Test name Executions per second
Ternary with Concat 812205.2 Ops/sec
Traditional If/Else with Concat 791233.1 Ops/sec