Skip to content

Instantly share code, notes, and snippets.

@kouba-c
Created May 13, 2014 14:12
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 kouba-c/de49f43915b2ca6d5ae8 to your computer and use it in GitHub Desktop.
Save kouba-c/de49f43915b2ca6d5ae8 to your computer and use it in GitHub Desktop.
require 'benchmark'
#ruby2.1.0
#x64
fixnum_max = 4611686018427387903
bignum_min = fixnum_max + 1
#Fixnum
Benchmark.bm do |b|
b.report do
(0..fixnum_max).step(100000000000) {|n|}
end
end
#Bignum
Benchmark.bm do |b|
b.report do
(bignum_min..(bignum_min + fixnum_max)).step(100000000000) {|n|}
end
end
# user system total real
# 2.100000 0.010000 2.110000 ( 2.201473)
# user system total real
# 11.400000 0.060000 11.460000 ( 12.068350)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment