-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotter.rb
More file actions
executable file
·90 lines (76 loc) · 1.67 KB
/
Copy pathplotter.rb
File metadata and controls
executable file
·90 lines (76 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env ruby
require 'gnuplot'
(p "Files to parse not specified";exit) if ARGV[0].nil?
# Class instance is created for each file passed to script
class FCount
attr_accessor :cvals, :fname
def initialize
@cvals = {}
end
def cdel(k)
@cvals.delete(k)
end
# Count number of requests at a particular time
def countme(num)
num = num.to_i
if @cvals[num].nil?
@cvals[num] = 1
else
@cvals[num] = @cvals[num] + 1
end
end
# File Loader
def fload(f)
File.open(f).each do |line|
fi=0
next if line =~ /time/
line.split("\t").each do |field|
fi += 1
if fi == 5; self.countme(field) else next end
end
end
end
end
$Files = []
ARGV.each do |f|
fc = FCount.new
##
##===> Change the extension if needed
##
fc.fname = (File.basename(f, '.tsv'))
fc.fload(f)
$Files.push fc
end
#
# Filter - Cut off requests taking longer than this, helps to scale the graph.
#
cutoff = 500
#### This block can be commented out to disable cutoff
#=begin
$Files.each do |f|
f.cvals.each do |c|
f.cdel(c[0]) if c[0] > cutoff
end
end
#=end
Gnuplot.open do |gp|
Gnuplot::Plot.new( gp ) do |plot|
plot.terminal "png size 800,600"
##
##===> Set the path
##
plot.output "/home/test/#{ARGV[0]}.png"
plot.title "Number of the requests served within a certain time (ms)"
plot.ylabel "Requests"
plot.xlabel "Time (ms)"
plot.grid "xtics ytics"
$Files.each do |f|
x = f.cvals.keys.collect { |k| k.to_f }
y = f.cvals.values
plot.data << Gnuplot::DataSet.new( [x,y] ) do |ds|
ds.with = "lines"
ds.title = f.fname
end
end
end
end