Class: Mxrb::Benchmark
- Inherits:
-
Object
- Object
- Mxrb::Benchmark
- Defined in:
- lib/mxrb/benchmark.rb
Overview
Repeatable wall-clock benchmark for the main read-only MPR operations.
Instance Method Summary collapse
-
#initialize(path, iterations: 3, clock: Process.method(:clock_gettime)) ⇒ Benchmark
constructor
A new instance of Benchmark.
- #run ⇒ Object
Constructor Details
#initialize(path, iterations: 3, clock: Process.method(:clock_gettime)) ⇒ Benchmark
Returns a new instance of Benchmark.
8 9 10 11 12 13 |
# File 'lib/mxrb/benchmark.rb', line 8 def initialize(path, iterations: 3, clock: Process.method(:clock_gettime)) @path = File.(path) @iterations = Integer(iterations) @clock = clock raise ArgumentError, 'iterations must be between 1 and 100' unless (1..100).cover?(@iterations) end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 |
# File 'lib/mxrb/benchmark.rb', line 15 def run open_time, units = measure { Mxrb.open(@path) { _1.all_units.size } } index_time, = measure { Mxrb.open(@path) { _1.semantic_index.artifacts.size } } validate_time, = measure { Mxrb.validate(@path).valid? } BenchmarkResult.new(@iterations, open_time, index_time, validate_time, units) end |