Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
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
Test name
Executions per second
test1: if
1364704.9 Ops/sec
test2: callback
1230166.2 Ops/sec
test3: currying
1204689.1 Ops/sec
test3_1: currying reverse
1519401.4 Ops/sec
test4: currying in try...catch
1266328.6 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);