Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
exception flow control vs. if-else
A comparison between utilizing a thrown exception to control flow vs. an if-else.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
try-catch control flow (no exception)
87.9M/s
if-else (hits else)
85.6M/s
if-else (hits if)
82.2M/s
try-catch control flow (thrown exception)
197K/s
View exact numbers
Test name
Executions per second
✓
try-catch control flow (no exception)
87,897,968 Ops/sec
if-else (hits else)
85,572,608 Ops/sec
if-else (hits if)
82,208,832 Ops/sec
try-catch control flow (thrown exception)
197,191 Ops/sec
Tests:
try-catch control flow (no exception)
const ok = true; let res; try { if (!ok) { throw new Error('ok = false'); } res = 1 + 1; } catch (e) { res = 1 + 2; }
try-catch control flow (thrown exception)
const ok = false; let res; try { if (!ok) { throw new Error('ok = false'); } res = 1 + 1; } catch (e) { res = 1 + 2; }
if-else (hits if)
const ok = true; let res; if (ok) { res = 1 + 1; } else { res = 1 + 2; }
if-else (hits else)
const ok = false; let res; if (ok) { res = 1 + 1; } else { res = 1 + 2; }