-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrapher.rb
executable file
·40 lines (33 loc) · 907 Bytes
/
grapher.rb
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
#!/usr/bin/env ruby
require 'fileutils'
require 'open3'
class App
def start
data_files = Dir.glob('data/*.tsv')
data_files.each do |data_file|
basename = File.basename(data_file, '.tsv')
gnuplot_commands = Utils.gnuplot_str(data_file)
image, s = Open3.capture2("gnuplot", :stdin_data=>gnuplot_commands, :binmode=>true)
if s.success?
STDOUT.binmode; print image
end
end
end
end
class Utils
def self.gnuplot_str(filename)
filebase = File.basename(filename, '.tsv')
<<-HERE .gsub(/^ {2}/, '')
set terminal png
set output "#{File.expand_path("graphs/#{filebase}.png")}"
set title "Benchmark #{filebase}"
set size 1,1
set key left top
set xlabel 'request'
set ylabel 'ms'
plot "#{File.expand_path(filename)}" using 10 with lines title 'Benchmark #{filebase}'
exit
HERE
end
end
App.new.start