comparison 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
comparison
equal deleted inserted replaced
22:d6d3b7180e6d 23:446a5c242cc7
1 #!/usr/local/bin/ruby
2
3 require './calc_sd_from_log.rb'
4 include CalcSD
5 include Math
6
7 $log="
8 1
9 2
10 3
11 4
12 5
13 "
14
15 #puts get_sigma_from_log("./cassandra_log/log/read_cassandra.o7518")
16
17 def log_parser(filename)
18 timeArray=[]
19 totalTime = 0
20 totalFailed = 0
21 timeStrArray = File.open(filename)do |file|
22 file.readlines.select{|line| line =~ /./ }
23 end
24 return timeStrArray.collect{|strTime| strTime.to_i }
25 end
26
27 def create_map(timeArray)
28 totalTime = 0
29 totalFailed = 0
30 timeArray.each {|time|
31 totalTime = totalTime + time
32 }
33 hashmap = {:totalTime => totalTime, :timeArray => timeArray, :totalFailed => totalFailed}
34 end
35
36 def main()
37 filename = (Time.now.to_i).to_s
38 puts "filename : "+filename
39 f = open(filename,"w")
40 f.puts $log
41 f.close()
42
43 timeArray = log_parser(filename)
44 File.delete(filename)
45 map = create_map(timeArray)
46 sigma = calclate_sigma(map)
47 puts sigma.to_s
48 puts Math.sqrt(2).to_s
49 end
50
51 main()
52