2012-02-14 11:21:07 -05:00
|
|
|
require 'digest/sha1'
|
|
|
|
|
|
|
|
def hash_of_file path
|
|
|
|
hash = Digest::SHA1.new
|
|
|
|
open(path,'r') do |io|
|
|
|
|
while !io.eof
|
|
|
|
buf = io.readpartial 1024
|
|
|
|
hash.update buf
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return hash.hexdigest
|
|
|
|
end
|
|
|
|
|
2012-12-16 07:36:47 -05:00
|
|
|
def profile_hash
|
2012-12-19 10:09:05 -05:00
|
|
|
@@profile_hashes ||= {}
|
|
|
|
@@profile_hashes[@profile] ||= hash_of_file "../profiles/#{@profile}.lua"
|
2012-02-14 11:21:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def osm_hash
|
|
|
|
@osm_hash ||= Digest::SHA1.hexdigest osm_str
|
|
|
|
end
|
|
|
|
|
|
|
|
def bin_extract_hash
|
2012-12-19 10:09:05 -05:00
|
|
|
@@bin_extract_hash ||= hash_of_file '../osrm-extract'
|
2012-02-14 11:21:07 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def bin_prepare_hash
|
2012-12-19 10:09:05 -05:00
|
|
|
@@bin_prepare_hash ||= hash_of_file '../osrm-prepare'
|
2012-02-14 11:21:07 -05:00
|
|
|
end
|
|
|
|
|
2012-02-24 08:55:15 -05:00
|
|
|
def bin_routed_hash
|
2012-12-19 10:09:05 -05:00
|
|
|
@@bin_routed_hash ||= hash_of_file '../osrm-routed'
|
2012-02-24 08:55:15 -05:00
|
|
|
end
|
|
|
|
|
2012-12-16 07:36:47 -05:00
|
|
|
#combine state of data, profile and binaries into a hash that identifies the exact test scenario
|
2012-02-14 11:21:07 -05:00
|
|
|
def fingerprint
|
2012-12-16 07:36:47 -05:00
|
|
|
@fingerprint ||= Digest::SHA1.hexdigest "#{bin_extract_hash}-#{bin_prepare_hash}-#{bin_routed_hash}-#{profile_hash}-#{osm_hash}"
|
2012-02-14 11:21:07 -05:00
|
|
|
end
|
|
|
|
|