Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Compare GCD
Compare GCD
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Bottom Up
68169672.0 Ops/sec
Top Down
34087308.0 Ops/sec
Good non-recursion
69692888.0 Ops/sec
Good Recusion
37456136.0 Ops/sec
Script Preparation code:
function gcd(a, b){ var divisor = 2, greatestDivisor = 1; if (a < 2 || b < 2) return 1; while(a >= divisor && b >= divisor){ if(a %divisor == 0 && b% divisor ==0){ greatestDivisor = divisor; } divisor++; } return greatestDivisor; } function gcd1(a,b){ var divisor = a < b ? a : b; if(a < 2 || b < 2){ return 1; } while(divisor > 0){ if(a % divisor === 0 && b % divisor === 0){ return divisor; } divisor--; } } function gcd2(a, b){ var x; while(b !== 0){ x = a % b; a = b; b = x; } return a; } function gcd3(a, b){ if(b === 0) return a; return gcd3(b, a % b); }
Tests:
Bottom Up
gcd(14, 21);
Top Down
gcd1(14, 21);
Good non-recursion
gcd2(14, 21);
Good Recusion
gcd3(14, 21);