Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Compare GCD
(version: 0)
Compare GCD
Comparing performance of:
Original vs Improvement vs Recursion vs Reverse Engineered Recursion vs Matt Solution
Created:
9 years ago
by:
Guest
Jump to the latest result
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); } function gcd4(a,b){ if (b === 0) { return a; } else { var remainder = a%b; return gcd4(b, remainder); } }
Tests:
Original
gcd(1012, 10580);
Improvement
gcd1(1012, 10580);
Recursion
gcd3(1012, 10580);
Reverse Engineered Recursion
gcd2(1012, 10580);
Matt Solution
gcd4(1012, 10580);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Original
Improvement
Recursion
Reverse Engineered Recursion
Matt Solution
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
Compare GCD
Compare GCD
Compare GCD
Compare GCD_
Comments
Confirm delete:
Do you really want to delete benchmark?