Class: Benchkit::BenchmarkScript
- Inherits:
-
Object
- Object
- Benchkit::BenchmarkScript
- Defined in:
- lib/benchkit.rb
Instance Attribute Summary collapse
- #loop_count ⇒ Integer readonly
- #name ⇒ String readonly
Instance Method Summary collapse
- #benchmark_script(iterations) ⇒ Object
- #inherit_root(prelude:, loop_count:) ⇒ Object
-
#initialize(name:, prelude: '', loop_count: nil, benchmark:) ⇒ BenchmarkScript
constructor
A new instance of BenchmarkScript.
- #overhead_script(iterations) ⇒ Object
Constructor Details
#initialize(name:, prelude: '', loop_count: nil, benchmark:) ⇒ BenchmarkScript
Returns a new instance of BenchmarkScript.
119 120 121 122 123 124 |
# File 'lib/benchkit.rb', line 119 def initialize(name:, prelude: '', loop_count: nil, benchmark:) @name = name @prelude = prelude @loop_count = loop_count @benchmark = benchmark end |
Instance Attribute Details
#loop_count ⇒ Integer (readonly)
130 131 132 |
# File 'lib/benchkit.rb', line 130 def loop_count @loop_count end |
#name ⇒ String (readonly)
127 128 129 |
# File 'lib/benchkit.rb', line 127 def name @name end |
Instance Method Details
#benchmark_script(iterations) ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/benchkit.rb', line 149 def benchmark_script(iterations) "\#{@prelude}\ni = 0\nwhile i < \#{iterations}\n i += 1\n\#{@benchmark}\nend\n RUBY\nend\n" |
#inherit_root(prelude:, loop_count:) ⇒ Object
132 133 134 135 136 137 |
# File 'lib/benchkit.rb', line 132 def inherit_root(prelude:, loop_count:) @prelude = "#{prelude}\n#{@prelude}" if @loop_count.nil? && loop_count @loop_count = loop_count end end |
#overhead_script(iterations) ⇒ Object
139 140 141 142 143 144 145 146 147 |
# File 'lib/benchkit.rb', line 139 def overhead_script(iterations) "\#{@prelude}\ni = 0\nwhile i < \#{iterations}\n i += 1\nend\n RUBY\nend\n" |