Class: TcpsnitchAnalyzer::TimeSerieStat

Inherits:
Object
  • Object
show all
Defined in:
lib/tcpsnitch_analyzer/time_serie_stat.rb

Constant Summary collapse

@@x =
[]
@@y =
[]

Class Method Summary collapse

Class Method Details

.add_point(timestamp, y) ⇒ Object



6
7
8
9
10
11
# File 'lib/tcpsnitch_analyzer/time_serie_stat.rb', line 6

def self.add_point(timestamp, y)
  usec = timestamp[:sec] * 1000000 + timestamp[:usec]
  @@min ||= usec
  @@x.push(usec-@@min)
  @@y.push(y)
end


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/tcpsnitch_analyzer/time_serie_stat.rb', line 13

def self.print(options)
  puts "Time serie plot"
  
  Gnuplot.open do |gp|
    Gnuplot::Plot.new(gp) do |plot|
      plot.title  "Time serie: #{options.node_path}(t)"
      plot.xlabel "Micro seconds"
      plot.ylabel options.node_path.split('.').last.capitalize
    
      plot.data << Gnuplot::DataSet.new([@@x,@@y]) do |ds|
        ds.with = "lines"
        ds.linewidth = 4
        ds.notitle
      end
    end
  end # Gnuplot.open
end