Module: Benchmark::Memory

Included in:
Benchmark
Defined in:
lib/benchmark/memory.rb,
lib/benchmark/memory/job.rb,
lib/benchmark/memory/errors.rb,
lib/benchmark/memory/report.rb,
lib/benchmark/memory/helpers.rb,
lib/benchmark/memory/version.rb,
lib/benchmark/memory/job/task.rb,
lib/benchmark/memory/measurement.rb,
lib/benchmark/memory/held_results.rb,
lib/benchmark/memory/report/entry.rb,
lib/benchmark/memory/job/io_output.rb,
lib/benchmark/memory/job/null_output.rb,
lib/benchmark/memory/report/comparison.rb,
lib/benchmark/memory/measurement/metric.rb,
lib/benchmark/memory/held_results/serializer.rb,
lib/benchmark/memory/held_results/entry_serializer.rb,
lib/benchmark/memory/job/io_output/entry_formatter.rb,
lib/benchmark/memory/held_results/metric_serializer.rb,
lib/benchmark/memory/job/io_output/metric_formatter.rb,
lib/benchmark/memory/job/io_output/comparison_formatter.rb,
lib/benchmark/memory/held_results/measurement_serializer.rb

Overview

Benchmark memory usage in code to benchmark different approaches.

Defined Under Namespace

Modules: Helpers Classes: HeldResults, Job, Measurement, Report

Constant Summary collapse

Error =
Class.new(StandardError)
ConfigurationError =
Class.new(Error)
VERSION =
"0.1.2".freeze

Instance Method Summary collapse

Instance Method Details

#memory(quiet: false) {|job| ... } ⇒ Report

Measure memory usage in report blocks.

Parameters:

  • quiet (Boolean) (defaults to: false)

    A flag to toggle benchmark output.

Yields:

  • (job)

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/benchmark/memory.rb', line 15

def memory(quiet: false)
  unless block_given?
    fail(
      ConfigurationError,
      "You did not give a test block to your call to `Benchmark.memory`"
    )
  end

  job = Job.new(:quiet => quiet)

  yield job

  job.run
  job.run_comparison
  job.full_report
end