Class: Benchmark::IPS::Report::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/benchmark/ips/report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, us, iters, ips, ips_sd, cycles) ⇒ Entry

Returns a new instance of Entry.



8
9
10
11
12
13
14
15
# File 'lib/benchmark/ips/report.rb', line 8

def initialize(label, us, iters, ips, ips_sd, cycles)
  @label = label
  @microseconds = us
  @iterations = iters
  @ips = ips
  @ips_sd = ips_sd
  @measurement_cycle = cycles
end

Instance Attribute Details

#ipsObject (readonly)

Returns the value of attribute ips.



17
18
19
# File 'lib/benchmark/ips/report.rb', line 17

def ips
  @ips
end

#ips_sdObject (readonly)

Returns the value of attribute ips_sd.



17
18
19
# File 'lib/benchmark/ips/report.rb', line 17

def ips_sd
  @ips_sd
end

#iterationsObject (readonly)

Returns the value of attribute iterations.



17
18
19
# File 'lib/benchmark/ips/report.rb', line 17

def iterations
  @iterations
end

#labelObject (readonly)

Returns the value of attribute label.



17
18
19
# File 'lib/benchmark/ips/report.rb', line 17

def label
  @label
end

#measurement_cycleObject (readonly)

Returns the value of attribute measurement_cycle.



17
18
19
# File 'lib/benchmark/ips/report.rb', line 17

def measurement_cycle
  @measurement_cycle
end

#microsecondsObject (readonly)

Returns the value of attribute microseconds.



17
18
19
# File 'lib/benchmark/ips/report.rb', line 17

def microseconds
  @microseconds
end

Instance Method Details

#bodyObject



29
30
31
32
# File 'lib/benchmark/ips/report.rb', line 29

def body
  left = "%10.1f (±%.1f%%) i/s" % [ips, stddev_percentage]
  left.ljust(20) + (" - %10d in %10.6fs" % [@iterations, runtime])
end

#displayObject



42
43
44
# File 'lib/benchmark/ips/report.rb', line 42

def display
  $stdout.puts to_s
end

#headerObject



34
35
36
# File 'lib/benchmark/ips/report.rb', line 34

def header
  @label.rjust(20)
end

#secondsObject Also known as: runtime



19
20
21
# File 'lib/benchmark/ips/report.rb', line 19

def seconds
  @microseconds.to_f / 1_000_000.0
end

#stddev_percentageObject



23
24
25
# File 'lib/benchmark/ips/report.rb', line 23

def stddev_percentage
  100.0 * (@ips_sd.to_f / @ips.to_f)
end

#to_sObject



38
39
40
# File 'lib/benchmark/ips/report.rb', line 38

def to_s
  "#{header} #{body}"
end