Skip to content

Instantly share code, notes, and snippets.

@sam
Last active December 11, 2015 13:38
Show Gist options
  • Save sam/4608953 to your computer and use it in GitHub Desktop.
Save sam/4608953 to your computer and use it in GitHub Desktop.
Scala vs Ruby. Silly benchmarks.
require "benchmark"
10.times do
Benchmark::bm do |x|
x.report do
1_000_000.times { |i| i ** 2 }
end
end
end
new testing.Benchmark {
def run = (1 to 1000000).map(i => Math.pow(i,2))
}.runBenchmark(10)
// But wait! There's more! Multi-threaded!
new testing.Benchmark {
def run = (1 to 1000000).par.map(i => Math.pow(i,2))
}.runBenchmark(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment