Skip to content

Instantly share code, notes, and snippets.

@kaiwren
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaiwren/9a2d3bd2072db7e4f2c3 to your computer and use it in GitHub Desktop.
Save kaiwren/9a2d3bd2072db7e4f2c3 to your computer and use it in GitHub Desktop.
Opal Microbenchmarks from github.com/kaiwren/redson
JS.Benchmarks.fact = function(n){
if(n > 1) {
return n * this.fact(n-1);
}
else {
return 1;
}
}
module Benchmarks
def self.fact(n)
if (n > 1)
n * fact(n-1)
else
1
end
end
end
JS.Benchmarks.fib = function(n){
return n < 2 ? n : this.fib(n - 1) + this.fib(n - 2);
}
module Benchmarks
def self.fib(n)
n < 2 ? n : fib(n - 1) + fib(n - 2)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment