Sha256: 938576154d0b233721b6482762f92cb0ed70ceef3893458a5642eb62002828e0
Contents?: true
Size: 863 Bytes
Versions: 5
Compression:
Stored size: 863 Bytes
Contents
require 'benchmark/ips' metadata = { :file_path => "some/path.rb" } meta_with_absolute = metadata.merge(:absolute_file_path => File.expand_path(metadata[:file_path])) Benchmark.ips do |x| x.report("fetch absolute path from hash") do meta_with_absolute[:absolute_file_path] end x.report("calculate absolute path") do File.expand_path(metadata[:file_path]) end end __END__ Precalculating the absolute file path is much, much faster! Calculating ------------------------------------- fetch absolute path from hash 102.164k i/100ms calculate absolute path 9.331k i/100ms ------------------------------------------------- fetch absolute path from hash 7.091M (±11.6%) i/s - 34.736M calculate absolute path 113.141k (± 8.6%) i/s - 569.191k
Version data entries
5 entries across 5 versions & 1 rubygems