Class: Perfer::RGrapher

Inherits:
Object
  • Object
show all
Defined in:
lib/perfer/grapher/r_grapher.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRGrapher

Returns a new instance of RGrapher.



4
5
6
7
# File 'lib/perfer/grapher/r_grapher.rb', line 4

def initialize
  require 'rinruby'
  @r = RinRuby.new(false, false)
end

Instance Attribute Details

#rObject (readonly)

Returns the value of attribute r.



3
4
5
# File 'lib/perfer/grapher/r_grapher.rb', line 3

def r
  @r
end

Instance Method Details

#boxplot(results) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/perfer/grapher/r_grapher.rb', line 9

def boxplot(results)
  data = results.map { |result|
    result.data.map { |m| m[:real]/result[:iterations] }
  }

  data.each_with_index { |d,i| r.assign("data#{i}", d) }
  r.data_rownames = results.map { |result| Formatter.short_ruby_description(result[:ruby]) }
  r.main_title = "#{results.first[:session]} : #{results.first[:job]}"
  r.eval <<-EOR
  pdf("graph.pdf", paper="a4", height=12)
  data = list(#{data.size.times.map { |i| "data#{i}" } * ',' })
  names(data) = data_rownames
  par(mar=c(20,4,4,2), las=2, cex.axis=.8)
  boxplot(data, main=main_title)
  EOR
end