Module: BenchPress

Defined in:
lib/bench_press.rb,
lib/bench_press/cli.rb,
lib/bench_press/report.rb,
lib/bench_press/result.rb,
lib/bench_press/runnable.rb,
lib/bench_press/ruby_benchmark.rb,
lib/bench_press/system_information.rb

Defined Under Namespace

Modules: SystemInformation Classes: CLI, Report, Result, RubyBenchmark, Runnable

Constant Summary collapse

VERSION =
'0.3.1'

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.currentObject (readonly)

Returns the value of attribute current.



17
18
19
# File 'lib/bench_press.rb', line 17

def current
  @current
end

.run_at_exitObject Also known as: run_at_exit?

Returns the value of attribute run_at_exit.



19
20
21
# File 'lib/bench_press.rb', line 19

def run_at_exit
  @run_at_exit
end

Class Method Details

.extended(base) ⇒ Object



22
23
24
25
# File 'lib/bench_press.rb', line 22

def extended(base)
  base.instance_variable_set(:@module_name, base.to_s) if base.is_a?(Module)
  @current = base
end

.titleize(string) ⇒ Object



30
31
32
33
34
# File 'lib/bench_press.rb', line 30

def self.titleize(string)
  string.split(/[\W_]+/).map do |word|
    word.capitalize
  end.join(" ")
end

Instance Method Details

#author(author) ⇒ Object



64
65
66
# File 'lib/bench_press.rb', line 64

def author(author)
  report.author = author
end

#bench_pressObject



80
81
82
83
# File 'lib/bench_press.rb', line 80

def bench_press
  report.runnables = runnables
  report
end

#date(date) ⇒ Object



48
49
50
# File 'lib/bench_press.rb', line 48

def date(date)
  report.date = Time.parse(date)
end

#email(email) ⇒ Object



68
69
70
# File 'lib/bench_press.rb', line 68

def email(email)
  report.email = email
end

#measure(name, &block) ⇒ Object



76
77
78
# File 'lib/bench_press.rb', line 76

def measure(name, &block)
  runnables << Runnable.new(name, block)
end

#module_nameObject



36
37
38
# File 'lib/bench_press.rb', line 36

def module_name
  @module_name
end

#name(new_report_name = nil) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/bench_press.rb', line 52

def name(new_report_name=nil)
  if new_report_name
    report.name = new_report_name
  else
    super()
  end
end

#reportObject



44
45
46
# File 'lib/bench_press.rb', line 44

def report
  @report ||= Report.new report_name
end

#reps(times) ⇒ Object



72
73
74
# File 'lib/bench_press.rb', line 72

def reps(times)
  Runnable.repetitions = times
end

#runnablesObject



40
41
42
# File 'lib/bench_press.rb', line 40

def runnables
  @runnables ||= []
end

#summary(summary) ⇒ Object



60
61
62
# File 'lib/bench_press.rb', line 60

def summary(summary)
  report.summary = summary
end