author | Claus Gittinger <cg@exept.de> |
Fri, 17 Aug 2018 18:45:10 +0200 | |
branch | cvs_MAIN |
changeset 3795 | b696900fb824 |
parent 2598 | 94ae3f5f4df1 |
permissions | -rwxr-xr-x |
#!/usr/bin/env ruby require 'benchmark' def run_hash_test(n) table = {} count = 0 1.upto(n) do |idx| table[idx.to_s(16)] = idx end 1.upto(n) do |idx| if table.has_key?(idx.to_s(10)) count = count + 1 end end end results = Benchmark.bmbm do |bm| raise "Expecting one arg - num of iterations" if ARGV.size == 0 n = ARGV[0].to_i bm.report { run_hash_test(n) } end puts "EXECUTION TIME: #{results[0].real * 1000.0}"