Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
try/catch or if ?
(version: 1)
Comparing performance of:
with if vs with try/catch
Created:
6 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
Tests:
with if
const sessionParams = JSON.parse(sessionStorage.getItem('params')); if (Array.isArray(sessionParams)) { for (const param of sessionParams) { console.log('param', param); } } else { console.log('if error'); }
with try/catch
const sessionParams = JSON.parse(sessionStorage.getItem('params')); try { for (const param of sessionParams) { console.log('param', param); } } catch { console.log('catch error'); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
with if
with try/catch
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser/OS:
Firefox 147 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
with if
182014.8 Ops/sec
with try/catch
92356.9 Ops/sec
Related benchmarks:
cookies vs sessionStorage
try catch15
Lodash vs Vanilla JS Test
!!a && b or a && b
if condition speed test 3
zargazrgzragzra
filter unsafe token
filter unsafe token 10w
normal vs eval fqeret
Comments
Confirm delete:
Do you really want to delete benchmark?