U:RDoc::AnyMethod[iI" bmbm:ETI"Benchmark#bmbm;TF:privateo:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"BSometimes benchmark results are skewed because code executed ;TI"Dearlier encounters different garbage collection overheads than ;TI"Gthat run later. #bmbm attempts to minimize this effect by running ;TI"Hthe tests twice, the first time as a rehearsal in order to get the ;TI"5runtime environment stable, the second time for ;TI"<real. GC.start is executed before the start of each of ;TI"?the real timings; the cost of this is not included in the ;TI"Ftimings. In reality, though, there's only so much that #bmbm can ;TI"Hdo, and the results are not guaranteed to be isolated from garbage ;TI""collection and other effects.;To:RDoc::Markup::BlankLine o;
; [I">Because #bmbm takes two passes through the tests, it can ;TI"(calculate the required label width.;T@o:RDoc::Markup::Verbatim; [
I"require 'benchmark'
;TI"
;TI"'array = (1..1000000).map { rand }
;TI"
;TI"Benchmark.bmbm do |x|
;TI"- x.report("sort!") { array.dup.sort! }
;TI"- x.report("sort") { array.dup.sort }
;TI" end
;T:@format0o;
; [I"Generates:;T@o;; [
I"9Rehearsal -----------------------------------------
;TI"9sort! 1.440000 0.010000 1.450000 ( 1.446833)
;TI"9sort 1.440000 0.000000 1.440000 ( 1.448257)
;TI"9-------------------------------- total: 2.890000sec
;TI"
;TI"8 user system total real
;TI"9sort! 1.460000 0.000000 1.460000 ( 1.458065)
;TI"9sort 1.450000 0.000000 1.450000 ( 1.455963)
;T;
0o;
; [I"B#bmbm yields a Benchmark::Job object and returns an array of ;TI"Benchmark::Tms objects.;T:
@fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I"job;T[ I"(width = 0);T@7FI"Benchmark;TcRDoc::NormalModule00