GCD via Euclidean algorithm

Benchmark created on


Description

Tail-call optimization benchmark of Euclidean algorithm implementations from:

https://stackoverflow.com/a/17445304

https://stackoverflow.com/questions/17445231/js-how-to-find-the-greatest-common-divisor#comment130208667_17445304

Preparation HTML

<script>
var gcdOriginal = function(a, b) {
  if (!b) {
    return a;
  }
  return gcdOriginal(b, a % b);
}

function gcdSuggested(a, b) {
  while (b) {
  	[a, b] = [b, a % b];
  }
  return a;
}

var a = 1024;
var b = 768;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
original implementation
gcdOriginal(a,b)
ready
suggested implementation
gcdSuggested(a,b)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.