spec/benchmarks/bignum_fixing.rb in logstash-output-scalyr-0.1.26.beta vs spec/benchmarks/bignum_fixing.rb in logstash-output-scalyr-0.2.0.beta

- old
+ new

@@ -1,18 +1,15 @@ require 'benchmark' require 'quantile' require_relative '../../lib/scalyr/common/util' +require_relative './util' # Micro benchmark which measures how long it takes to find all the Bignums in a record and convert them to strings ITERATIONS = 500 -def rand_str(len) - return (0...len).map { (65 + rand(26)).chr }.join -end - def rand_bignum() return 200004000020304050300 + rand(999999) end def generate_hash(widths) @@ -41,10 +38,10 @@ puts "Using %s total keys in a hash" % [Scalyr::Common::Util.flatten(data[0]).count] puts "" result = [] ITERATIONS.times do |i| - result << Benchmark.measure { run_benchmark_func.(data[0]) } + result << Benchmark.measure { run_benchmark_func.(data[i]) } end sum = result.inject(nil) { |sum, t| sum.nil? ? sum = t : sum += t } avg = sum / result.size