Skip to content

Instantly share code, notes, and snippets.

@bloopletech
Created July 7, 2009 00:16
Show Gist options
  • Save bloopletech/141785 to your computer and use it in GitHub Desktop.
Save bloopletech/141785 to your computer and use it in GitHub Desktop.
require 'benchmark'
def bench_small
puts Benchmark.measure {
1.upto(10_000) { |n| n.humanize }
}
end
def bench_large
puts Benchmark.measure {
1_000_000_000_000_000_000_000_000_000_000_000_000_000_000.upto(1_000_000_000_000_000_000_000_000_000_000_000_000_010_000) { |n| n.humanize }
}
end
require 'humanize/lib/humanize'
puts "Times for Radar's small"
10.times { bench_small }
puts "Times for Radar's large"
10.times { bench_large }
#Numeric.send(:remove_method, :humanize)
require 'humanize_numbers'
puts "Times for mine small"
10.times { bench_small }
puts "Times for mine large"
10.times { bench_large }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment