Class: Benchable::Benchmark
- Inherits:
-
Object
- Object
- Benchable::Benchmark
- Defined in:
- lib/benchable/benchmark.rb
Constant Summary collapse
- DEFAULT_WIDTH =
20- BENCHMARK_TYPES =
i[bm bmbm ips memory].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #cases ⇒ Object
-
#initialize(benchmark_type, options = {}) ⇒ Benchmark
constructor
A new instance of Benchmark.
- #run ⇒ Object
- #setup ⇒ Object
Constructor Details
#initialize(benchmark_type, options = {}) ⇒ Benchmark
Returns a new instance of Benchmark.
12 13 14 15 16 17 |
# File 'lib/benchable/benchmark.rb', line 12 def initialize(benchmark_type, = {}) @benchmark_type = benchmark_type = raise Error, "Invalid benchmark type '#{benchmark_type}'" unless valid_benchmark_type? end |
Class Method Details
.bench(name, &block) ⇒ Object
23 24 25 |
# File 'lib/benchable/benchmark.rb', line 23 def self.bench(name, &block) define_method(method_name_for(name), &block) end |
.setup(&block) ⇒ Object
19 20 21 |
# File 'lib/benchable/benchmark.rb', line 19 def self.setup(&block) define_method(:setup, &block) end |
Instance Method Details
#cases ⇒ Object
34 35 36 |
# File 'lib/benchable/benchmark.rb', line 34 def cases public_methods.grep(/\Abench_/) end |
#run ⇒ Object
29 30 31 32 |
# File 'lib/benchable/benchmark.rb', line 29 def run setup run_benchmark end |
#setup ⇒ Object
27 |
# File 'lib/benchable/benchmark.rb', line 27 def setup; end |