Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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/131.0.0.0 Safari/537.36
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Good non-recursion
38.9M/s
Good Recusion
22.3M/s
Bottom Up
15.9M/s
Top Down
14.3M/s
View exact numbers
Test name
Executions per second
✓
Good non-recursion
38,875,168 Ops/sec
Good Recusion
22,250,468 Ops/sec
Bottom Up
15,883,154 Ops/sec
Top Down
14,345,156 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);