#!/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()