class ComplexityAssert::Sampler
Public Class Methods
new(algo_under_test)
click to toggle source
# File lib/complexity_assert/sampler.rb, line 6 def initialize(algo_under_test) @algo_under_test = algo_under_test end
Public Instance Methods
run(sizes, rounds)
click to toggle source
Generates an array of sample data points
- [input size, real time], …
# File lib/complexity_assert/sampler.rb, line 12 def run(sizes, rounds) sizes.flat_map { |size | run_for_size(size, rounds) } end
Private Instance Methods
run_for_size(size, rounds)
click to toggle source
# File lib/complexity_assert/sampler.rb, line 18 def run_for_size(size, rounds) Array.new(rounds) do args = @algo_under_test.generate_args(size) GC.disable real_time = Benchmark.realtime { @algo_under_test.run(*args) } GC.enable [size, real_time] end end