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