Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
if vs callback vs currying condition comparison ver_2: static handle
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
test3_1: currying reverse
1.5M/s
test1: if
1.4M/s
test4: currying in try...catch
1.3M/s
test2: callback
1.2M/s
test3: currying
1.2M/s
View exact numbers
Test name
Executions per second
✓
test3_1: currying reverse
1,519,401 Ops/sec
test1: if
1,364,705 Ops/sec
test4: currying in try...catch
1,266,329 Ops/sec
test2: callback
1,230,166 Ops/sec
test3: currying
1,204,689 Ops/sec
Script Preparation code:
function getRandomInt(max) { return Math.floor(Math.random() * max); } function handle(v) { console.log(`${v} >= 50`); } function test1(v) { v >= 50 && console.log(`${v} >= 50`); } function test2(v, fn) { v >= 50 && typeof fn === 'function' && fn(v); } function test3(v) { return (fn) => v >= 50 && typeof fn === 'function' && fn(v); } function test3_1(fn) { return typeof fn === 'function' ? (v) => v >= 50 && fn(v) : undefined; } function test4(v) { return (fn) => { try { v >= 50 && fn(v); } catch (e) { } }; }
Tests:
test1: if
test1(getRandomInt(100));
test2: callback
test2(getRandomInt(100), handle);
test3: currying
test3(getRandomInt(100))(handle);
test3_1: currying reverse
test3_1(handle)(getRandomInt(100));
test4: currying in try...catch
test4(getRandomInt(100))(handle);