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/comparator.rb,
lib/benchmark/memory/report/comparison.rb,
lib/benchmark/memory/measurement/metric.rb,
lib/benchmark/memory/human_readable_unit.rb,
lib/benchmark/memory/held_results/serializer.rb,
lib/benchmark/memory/measurement/metric_extractor.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, HumanReadableUnit, Job, Measurement, MetricExtractor, Report

Constant Summary collapse

Error =
Class.new(StandardError)
ConfigurationError =
Class.new(Error) do
  def message
    'You did not give a test block to your call to `Benchmark.memory`'
  end
end
VERSION =
'0.2.0'

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:

Raises:



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

def memory(quiet: false)
  raise ConfigurationError unless block_given?

  job = Job.new(quiet: quiet)

  yield job

  job.run
  job.run_comparison
  job.full_report
end