Skip to content
Browse files

Add benchmark for Integer#gcd

  • Loading branch information...
1 parent e5ec5aa commit 734a9bf8e2c862ce2ca14b10efa3c816aef23bf0 @dbussink dbussink committed Jan 11, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 benchmark/core/integer/bench_gcd.rb
View
19 benchmark/core/integer/bench_gcd.rb
@@ -0,0 +1,19 @@
+require 'benchmark'
+require 'benchmark/ips'
+require 'benchmark/helpers'
+require 'rational'
+
+Benchmark.ips do |x|
+
+ small_fixnum = 10000
+ big_fixnum = Benchmark::Helpers.fixnum_max
+
+ x.report "Fixnum gcd Fixnum => Fixnum" do |times|
+ i = 0
+ while i < times
+ big_fixnum.gcd(small_fixnum)
+ i += 1
+ end
+ end
+
+end

0 comments on commit 734a9bf

Please sign in to comment.
Something went wrong with that request. Please try again.