Binary search & linear search with different runtime engines with different array sizes

I am very impressed by the V8 performance. Note that all the test are performed in a “cold start” environment (Chrome will be even faster when it’s pre-warmed). Nginx JS module timing does not include VM creation time, it’s simply how long it takes for Javascript includes to return.

3 arrays are all sorted for both linear search and binary search.

Side note: Check Spectre mitigation info https://developer.mozilla.org/en-US/docs/Web/API/Performance/now

Chrome V8 (Chrome 75.0.3770.100):

Testing performance diff for 864 elements
VM53:39 JS Includes: 0.0004742914331339199
VM53:40 Binary Find: 0.0005485737978535121

badASNRAM1000:
Testing performance diff for 1000 elements
VM35:39 JS Includes: 0.0005819572611686687
VM35:40 Binary Find: 0.000597040518428322

badASNRAM2000:
Testing performance diff for 2000 elements
VM35:39 JS Includes: 0.0006530127825462825
VM35:40 Binary Find: 0.0005997027038064568

badASNRAM2000:
Testing performance diff for 3000 elements
VM35:40 JS Includes: 0.0007289954804322399
VM35:41 Binary Find: 0.0006195246703701701

Nginx Javascript Module (0.3.2):

Testing performance diff for 864 elements
JS Includes: 0.003342809388437308
Binary Find: 0.005385637348037885

Testing performance diff for 1000 elements
JS Includes: 0.003771374694647219
Binary Find: 0.0055713489807288469

Testing performance diff for 2000 elements
JS Includes: 0.007814174083227382
Binary Find: 0.005828488164454793

Testing performance diff for 3000 elements
JS Includes: 0.010571277553177812
Binary Find: 0.006385623062527678

Firefox (67.0.4):

Testing performance diff for 864 elements
JS Includes: 0.002390261262875734
Binary Find: 0.0029657412712555307

Testing performance diff for 1000 elements
JS Includes: 0.0023732933018800486
Binary Find: 0.003145328472371149

Testing performance diff for 2000 elements
JS Includes: 0.003987537159844501
Binary Find: 0.0030871255431054196

Testing performance diff for 3000 elements
JS Includes: 0.005244880168064825
Binary Find: 0.003329855801523445

Unless otherwise specified, all articles are original and protected by the copyright law; If you would like to reprint the article(s), please contact me.