Sha256: c730b08ccb32fb75fec5f85fe567239c6d4d483061bd1bbadf195fc0d8005d6c
Contents?: true
Size: 499 Bytes
Versions: 15
Compression:
Stored size: 499 Bytes
Contents
module WBench class TimingHash < Hash def initialize(hash) # Remove 0 values as they indicate events that didn't occur hash = hash.delete_if { |key, value| value == 0 } # Grab the start time and offset the values against it. start_time = hash.min_by(&:last).last hash = hash.map { |key, value| [key, value - start_time] } # Order the results by value, lowest to highest hash.sort_by(&:last).each { |key, value| self[key] = value } end end end
Version data entries
15 entries across 15 versions & 1 rubygems