Mercurial > hg > Members > nobuyasu > jungle_benchmark
diff distributed/weighttp/test_calc_sd_from_log.rb @ 23:446a5c242cc7
Added test_calc_sd_from_log.rb
author | Nobuyasu |
---|---|
date | Thu, 30 Jan 2014 23:31:30 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distributed/weighttp/test_calc_sd_from_log.rb Thu Jan 30 23:31:30 2014 +0900 @@ -0,0 +1,52 @@ +#!/usr/local/bin/ruby + +require './calc_sd_from_log.rb' +include CalcSD +include Math + +$log=" +1 +2 +3 +4 +5 +" + +#puts get_sigma_from_log("./cassandra_log/log/read_cassandra.o7518") + +def log_parser(filename) + timeArray=[] + totalTime = 0 + totalFailed = 0 + timeStrArray = File.open(filename)do |file| + file.readlines.select{|line| line =~ /./ } + end + return timeStrArray.collect{|strTime| strTime.to_i } +end + +def create_map(timeArray) + totalTime = 0 + totalFailed = 0 + timeArray.each {|time| + totalTime = totalTime + time + } + hashmap = {:totalTime => totalTime, :timeArray => timeArray, :totalFailed => totalFailed} +end + +def main() + filename = (Time.now.to_i).to_s + puts "filename : "+filename + f = open(filename,"w") + f.puts $log + f.close() + + timeArray = log_parser(filename) + File.delete(filename) + map = create_map(timeArray) + sigma = calclate_sigma(map) + puts sigma.to_s + puts Math.sqrt(2).to_s +end + +main() +