#!/usr/bin/env ruby -W0 def parseLine(line) line = line.sub /bytes_accessed_hist: \[/, '' line.chop! hist = line.split " " return [0,0,0] if hist[0] != '0' total_accesses = 0 total_word_accesses = 0 hist.each_index { |idx| total_accesses += hist[idx].to_i total_word_accesses += hist[idx].to_i if idx <= 4 } total_bytes_consumed = 0 hist.each_index { |idx| total_bytes_consumed += hist[idx].to_i * idx } return [total_accesses, total_word_accesses, total_bytes_consumed] end def printResults(total_transfers, total_word_transfers, total_bytes_consumed) puts "Total bytes transfered: \t\t#{total_transfers.to_i*64}" puts "Total bytes consumed: \t\t\t#{total_bytes_consumed}" puts "Wasted bytes transfered: \t\t#{(total_transfers.to_i*64) - total_bytes_consumed}" puts "Percent of bytes wated: \t\t#{(total_transfers.to_f*64 - total_bytes_consumed.to_f)/(total_transfers.to_f*64.0)*100.0}%" puts "Total transfers one word or less: \t#{total_word_transfers}" number_of_bytes_with_word = ((total_transfers.to_i - total_word_transfers.to_i)*64) + (total_word_transfers.to_i*4) puts "Number of bytes transfered with word transfers: \t#{number_of_bytes_with_word}" puts "Percent of bytes saved with one word transfers: \t#{((total_transfers.to_f*64.0 - number_of_bytes_with_word.to_f)/(total_transfers.to_f*64.0))*100.0}%" end root = File.dirname(File.expand_path(__FILE__)) total_transfers = 0 total_word_transfers = 0 total_bytes_consumed = 0 stat_files = Dir.glob("#{root}/../results/*/stats") stat_files.each { |stat_file| lines = `more #{stat_file} | grep bytes_accessed` workload_transfers = 0 workload_word_transfers = 0 workload_bytes_consumed = 0 lines.each_line { |line| result = parseLine(line) workload_transfers += result[0] workload_word_transfers += result[1] workload_bytes_consumed += result[2] } puts "Results for #{stat_file}" printResults(workload_transfers, workload_word_transfers, workload_bytes_consumed) puts total_transfers += workload_transfers total_word_transfers += workload_word_transfers total_bytes_consumed += workload_bytes_consumed } puts "Average results" printResults(total_transfers, total_word_transfers, total_bytes_consumed)