Skip to content

Instantly share code, notes, and snippets.

@dmalikov
Created March 7, 2013 22:39
Show Gist options
  • Save dmalikov/5112502 to your computer and use it in GitHub Desktop.
Save dmalikov/5112502 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'gnuplot'
require 'ostruct'
def read file
times = []
File.open(file).each do |line|
_,a,_ = line.split(' ')
times << Float(a)/1000000
end
return [(1..times.size).to_a, times]
end
tests = [
{ :filename => "assets_before_deleting_all.log",
:desc => "14:40 - 15:25 without deleting" },
{ :filename => "assets_after_first_deleting_test_all.log",
:desc => "15:30 - 15:50, deleting 150/30 assets/seconds" },
{ :filename => "assets_after_second_deleting_test_all.log",
:desc => "15:50 - 16:30, deleting 500/30 assets/seconds" },
{ :filename => "assets_after_third_deleting_test_all.log",
:desc => "16:30 - 17:15, deleting 500/30 assets/seconds" }
]
Gnuplot.open do |gp|
Gnuplot::Plot.new(gp) do |plot|
plot.xlabel "Asset number"
plot.ylabel "Time from first packet to flush, s"
plot.terminal "png size 1000,800"
plot.output File.expand_path "../results.png", __FILE__
plot.data = tests.map do |t|
Gnuplot::DataSet.new(read t[:filename]) do |ds|
ds.title = t[:desc]
ds.with = "lines"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment