Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Branchless vs Branched Angle Inversion
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
branchless
1779.2M/s
branchless in-scope caching
1777.6M/s
branched
597.3M/s
branchless out of scope caching
477.4M/s
View exact numbers
Test name
Executions per second
✓
branchless
1,779,229,184 Ops/sec
branchless in-scope caching
1,777,615,616 Ops/sec
branched
597,312,192 Ops/sec
branchless out of scope caching
477,350,048 Ops/sec
Script Preparation code:
const PI = Math.PI; function invertAngleBranch(angle) { if (angle + PI > PI) return (angle - PI) else return angle + PI }; function invertAngleBranchless(angle) { return (angle + PI > PI) * (angle - PI) + (angle + PI <= PI) * (angle + PI); }; function invertAngleBranchlessC1(angle) { let tmp = angle + PI; return (tmp > PI) * (angle - PI) + (tmp <= PI) * tmp; }; let tmp2 = NaN; //initialize with float for v8 function invertAngleBranchlessC2(angle) { tmp2 = angle + PI; return (tmp2 > PI) * (angle - PI) + (tmp2 <= PI) * tmp2; }; var rnd = Math.random;
Tests:
branched
return invertAngleBranch(rnd());
branchless
return invertAngleBranchless(rnd());
branchless in-scope caching
return invertAngleBranchlessC1(rnd());
branchless out of scope caching
return invertAngleBranchlessC2(rnd());