Created
April 15, 2013 16:35
-
-
Save bradland/5389396 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 jpeg size 1280,720 | |
set size 1, 1 | |
set output "#{File.expand_path("graphs/#{filebase}.jpg")}" | |
set title "Benchmark #{filebase}" | |
set key left top | |
set grid y | |
set xlabel 'request' | |
set ylabel "response time (ms)" | |
set datafile separator "\t" | |
plot "#{File.expand_path(filename)}" every ::2 using 5 with lines title 'response time' | |
# plot "#{File.expand_path(filename)}" every ::2 using 5 smooth sbezier with lines title 'sbezier' | |
exit | |
HERE | |
end | |
end | |
App.new.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment