Class: Benchkit::BenchmarkRoot
- Inherits:
-
Object
- Object
- Benchkit::BenchmarkRoot
- Defined in:
- lib/benchkit.rb
Instance Attribute Summary collapse
- #benchmarks ⇒ Array<BenchmarkScript> readonly
Instance Method Summary collapse
-
#initialize(name:, prelude: '', loop_count: nil, benchmark: nil, benchmarks: []) ⇒ BenchmarkRoot
constructor
A new instance of BenchmarkRoot.
Constructor Details
#initialize(name:, prelude: '', loop_count: nil, benchmark: nil, benchmarks: []) ⇒ BenchmarkRoot
Returns a new instance of BenchmarkRoot.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/benchkit.rb', line 96 def initialize(name:, prelude: '', loop_count: nil, benchmark: nil, benchmarks: []) if benchmark unless benchmarks.empty? raise ArgumentError.new("Only either :benchmark or :benchmarks can be specified") end @benchmarks = [BenchmarkScript.new(name: name, prelude: prelude, benchmark: benchmark)] else @benchmarks = benchmarks.map do |hash| BenchmarkScript.new(Hash[hash.map { |k, v| [k.to_sym, v] }]).tap do |b| b.inherit_root(prelude: prelude, loop_count: loop_count) end end end end |
Instance Attribute Details
#benchmarks ⇒ Array<BenchmarkScript> (readonly)
112 113 114 |
# File 'lib/benchkit.rb', line 112 def benchmarks @benchmarks end |