Skip to content

Instantly share code, notes, and snippets.

@fsword
Created June 9, 2012 04:28
Show Gist options
  • Save fsword/2899473 to your computer and use it in GitHub Desktop.
Save fsword/2899473 to your computer and use it in GitHub Desktop.
prime benchmark
require './prime.rb' # user defined function
require 'benchmark'
require 'digest/md5'
result = {
4 => 'ae5161e4645f5cd58897d32f529f3ad5',
5 => 'cf7b5007830f057a04d2b696527952e7',
6 => 'a43beaed59a26b8d85868eaa8fa2e972',
7 => 'c1aa9bda24aa8bc5473ca1f51c9fd106'
}
Benchmark.bm do |x|
(4..6).each do |i|
x.report(10**i){ raise "wrong!" if Digest::MD5.hexdigest( prime(10**i).join(' ') )!= result[i] }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment