ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- measure-c.ri000064400000000570152375457070007002 0ustar00U:RDoc::AnyMethod[iI" measure:EFI"Benchmark::measure;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I";Returns the time used to execute the given block as a ;TI"Benchmark::Tms object.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I";T[I"(label = "");T@FI"Benchmark;FcRDoc::NormalModule00bmbm-c.ri000064400000003550152375457100006251 0ustar00U:RDoc::AnyMethod[iI" bmbm:EFI"Benchmark::bmbm;TT: publico: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"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;F[I"(width = 0);T@7FI"Benchmark;FcRDoc::NormalModule00realtime-c.ri000064400000000533152375457100007134 0ustar00U:RDoc::AnyMethod[iI" realtime:EFI"Benchmark::realtime;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"CReturns the elapsed real time used to execute the given block.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I";T[I"();T@FI"Benchmark;FcRDoc::NormalModule00benchmark-i.ri000064400000004050152375457100007270 0ustar00U:RDoc::AnyMethod[iI"benchmark:EFI"Benchmark#benchmark;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I">Invokes the block with a Benchmark::Report object, which ;TI"Dmay be used to collect and report on the results of individual ;TI"@benchmark tests. Reserves +label_width+ leading spaces for ;TI"=labels on each line. Prints +caption+ at the top of the ;TI"4report, and uses +format+ to format each line. ;TI"0Returns an array of Benchmark::Tms objects.;To:RDoc::Markup::BlankLineo; ; [ I"&If the block returns an array of ;TI":Benchmark::Tms objects, these will be used to format ;TI";additional lines of output. If +label+ parameters are ;TI"6given, these are used to label these extra lines.;T@o; ; [I"L_Note_: Other methods provide a simpler interface to this one, and are ;TI"Msuitable for nearly all benchmarking requirements. See the examples in ;TI".Benchmark, and the #bm and #bmbm methods.;T@o; ; [I" Example:;T@o:RDoc::Markup::Verbatim; [I"require 'benchmark' ;TI"Kinclude Benchmark # we need the CAPTION and FORMAT constants ;TI" ;TI"n = 5000000 ;TI"HBenchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| ;TI"? tf = x.report("for:") { for i in 1..n; a = "1"; end } ;TI"? tt = x.report("times:") { n.times do ; a = "1"; end } ;TI"? tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } ;TI" [tf+tt+tu, (tf+tt+tu)/3] ;TI" end ;T: @format0o; ; [I"Generates:;T@o; ; [ I": user system total real ;TI";for: 0.970000 0.000000 0.970000 ( 0.970493) ;TI";times: 0.990000 0.000000 0.990000 ( 0.989542) ;TI";upto: 0.970000 0.000000 0.970000 ( 0.972854) ;TI";>total: 2.930000 0.000000 2.930000 ( 2.932889) ;TI":>avg: 0.976667 0.000000 0.976667 ( 0.977630);T; 0: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I" report;F[I"=(caption = "", label_width = nil, format = nil, *labels);T@9FI"Benchmark;FcRDoc::NormalModule00cdesc-Benchmark.ri000064400000011453152375457100010066 0ustar00U:RDoc::NormalModule[iI"Benchmark:EF@0o:RDoc::Markup::Document: @parts[o;;[ o:RDoc::Markup::Paragraph;[I"JThe Benchmark module provides methods to measure and report the time ;TI"used to execute Ruby code.;To:RDoc::Markup::BlankLineo:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0;[ o; ;[I"FMeasure the time to construct the string given by the expression ;TI"$"a"*1_000_000_000:;T@o:RDoc::Markup::Verbatim;[I"require 'benchmark' ;TI" ;TI"2puts Benchmark.measure { "a"*1_000_000_000 } ;T: @format0o; ;[I"=On my machine (OSX 10.8.3 on i5 1.7 Ghz) this generates:;T@o;;[I"10.350000 0.400000 0.750000 ( 0.835234) ;T;0o; ;[I"FThis report shows the user CPU time, system CPU time, the sum of ;TI"Hthe user and system CPU times, and the elapsed real time. The unit ;TI"of time is seconds.;T@o;;0;[ o; ;[I";Do some experiments sequentially using the #bm method:;T@o;;[ I"require 'benchmark' ;TI" ;TI"n = 5000000 ;TI"Benchmark.bm do |x| ;TI"0 x.report { for i in 1..n; a = "1"; end } ;TI"0 x.report { n.times do ; a = "1"; end } ;TI"0 x.report { 1.upto(n) do ; a = "1"; end } ;TI" end ;T;0o; ;[I"The result:;T@o;;[ I"0 user system total real ;TI"11.010000 0.000000 1.010000 ( 1.014479) ;TI"11.000000 0.000000 1.000000 ( 0.998261) ;TI"10.980000 0.000000 0.980000 ( 0.981335) ;T;0o;;0;[o; ;[I"AContinuing the previous example, put a label in each report:;T@o;;[ I"require 'benchmark' ;TI" ;TI"n = 5000000 ;TI"Benchmark.bm(7) do |x| ;TI": x.report("for:") { for i in 1..n; a = "1"; end } ;TI": x.report("times:") { n.times do ; a = "1"; end } ;TI": x.report("upto:") { 1.upto(n) do ; a = "1"; end } ;TI" end ;T;0o; ;[I"The result:;T@o;;[ I": user system total real ;TI";for: 1.010000 0.000000 1.010000 ( 1.015688) ;TI";times: 1.000000 0.000000 1.000000 ( 1.003611) ;TI";upto: 1.030000 0.000000 1.030000 ( 1.028098) ;T;0o; ; ; ;[o;;0;[ o; ;[ I"FThe times for some benchmarks depend on the order in which items ;TI"?are run. These differences are due to the cost of memory ;TI"Fallocation and garbage collection. To avoid these discrepancies, ;TI"Dthe #bmbm method is provided. For example, to compare ways to ;TI"sort an array of floats:;T@o;;[ 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;0o; ;[I"The result:;T@o;;[ I"9Rehearsal ----------------------------------------- ;TI"9sort! 1.490000 0.010000 1.500000 ( 1.490520) ;TI"9sort 1.460000 0.000000 1.460000 ( 1.463025) ;TI"9-------------------------------- total: 2.960000sec ;TI" ;TI"8 user system total real ;TI"9sort! 1.460000 0.000000 1.460000 ( 1.460465) ;TI"9sort 1.450000 0.010000 1.460000 ( 1.448327) ;T;0o;;0;[ o; ;[I"EReport statistics of sequential experiments with unique labels, ;TI"!using the #benchmark method:;T@o;;[I"require 'benchmark' ;TI"Jinclude Benchmark # we need the CAPTION and FORMAT constants ;TI" ;TI"n = 5000000 ;TI"HBenchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| ;TI"? tf = x.report("for:") { for i in 1..n; a = "1"; end } ;TI"? tt = x.report("times:") { n.times do ; a = "1"; end } ;TI"? tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } ;TI" [tf+tt+tu, (tf+tt+tu)/3] ;TI" end ;T;0o; ;[I"The result:;T@o;;[ I"9 user system total real ;TI";for: 0.950000 0.000000 0.950000 ( 0.952039) ;TI";times: 0.980000 0.000000 0.980000 ( 0.984938) ;TI";upto: 0.950000 0.000000 0.950000 ( 0.946787) ;TI";>total: 2.880000 0.000000 2.880000 ( 2.883764) ;TI":>avg: 0.960000 0.000000 0.960000 ( 0.961255);T;0: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[[U:RDoc::Constant[iI" CAPTION;FI"Benchmark::CAPTION;T00o;;[o; ;[I"AThe default caption string (heading above the output times).;T;@“;0@“@cRDoc::NormalModule0U;[iI" FORMAT;FI"Benchmark::FORMAT;T00o;;[o; ;[I"VThe default format string used to display times. See also Benchmark::Tms#format.;T;@“;0@“@@Ÿ0[[[I" class;T[[: public[ [I"benchmark;FI"lib/benchmark.rb;T[I"bm;F@²[I" bmbm;F@²[I" measure;F@²[I" realtime;F@²[:protected[[: private[[I" instance;T[[;[[;[[;[ [@±@²[@´@²[@¶@²[@¸@²[@º@²[[U:RDoc::Context::Section[i0o;;[;0;0[@“@“cRDoc::TopLevelbm-i.ri000064400000002076152375457100005742 0ustar00U:RDoc::AnyMethod[iI"bm:EFI"Benchmark#bm;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"KA simple interface to the #benchmark method, #bm generates sequential ;TI"Greports with labels. The parameters have the same meaning as for ;TI"#benchmark.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"require 'benchmark' ;TI" ;TI"n = 5000000 ;TI"Benchmark.bm(7) do |x| ;TI": x.report("for:") { for i in 1..n; a = "1"; end } ;TI": x.report("times:") { n.times do ; a = "1"; end } ;TI": x.report("upto:") { 1.upto(n) do ; a = "1"; end } ;TI" end ;T: @format0o; ; [I"Generates:;T@o; ; [ I": user system total real ;TI";for: 0.960000 0.000000 0.960000 ( 0.957966) ;TI";times: 0.960000 0.000000 0.960000 ( 0.960423) ;TI":upto: 0.950000 0.000000 0.950000 ( 0.954864);T; 0: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I" report;F[I"(label_width = 0, *labels);T@$FI"Benchmark;FcRDoc::NormalModule00measure-i.ri000064400000000570152375457100007002 0ustar00U:RDoc::AnyMethod[iI" measure:EFI"Benchmark#measure;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I";Returns the time used to execute the given block as a ;TI"Benchmark::Tms object.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I";T[I"(label = "");T@FI"Benchmark;FcRDoc::NormalModule00Tms/format-i.ri000064400000002744152375457100007401 0ustar00U:RDoc::AnyMethod[iI" format:EFI"Benchmark::Tms#format;TF: publico:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"0Returns the contents of this Tms object as ;TI"6a formatted string, according to a format string ;TI"=like that passed to Kernel.format. In addition, #format ;TI"&accepts the following extensions:;To:RDoc::Markup::BlankLineo:RDoc::Markup::List: @type: NOTE: @items[ o:RDoc::Markup::ListItem: @label[I"%u;T; [o; ; [I"=Replaced by the user CPU time, as reported by Tms#utime.;To;;[I"%y;T; [o; ; [I"WReplaced by the system CPU time, as reported by #stime (Mnemonic: y of "s*y*stem");To;;[I"%U;T; [o; ; [I"HReplaced by the children's user CPU time, as reported by Tms#cutime;To;;[I"%Y;T; [o; ; [I"JReplaced by the children's system CPU time, as reported by Tms#cstime;To;;[I"%t;T; [o; ; [I"=Replaced by the total CPU time, as reported by Tms#total;To;;[I"%r;T; [o; ; [I"?Replaced by the elapsed real time, as reported by Tms#real;To;;[I"%n;T; [o; ; [I"UReplaced by the label string, as reported by Tms#label (Mnemonic: n of "*n*ame");T@o; ; [I"NIf _format_ is not given, FORMAT is used as default value, detailing the ;TI"(user, system and real elapsed time.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I"(format = nil, *args);T@IFI"Tms;TcRDoc::NormalClass00Tms/cutime-i.ri000064400000000450152375457100007367 0ustar00U:RDoc::Attr[iI" cutime:ETI"Benchmark::Tms#cutime;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"User CPU time of children;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/stime-i.ri000064400000000434152375457100007224 0ustar00U:RDoc::Attr[iI" stime:ETI"Benchmark::Tms#stime;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"System CPU time;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/to_a-i.ri000064400000000704152375457100007025 0ustar00U:RDoc::AnyMethod[iI" to_a:EFI"Benchmark::Tms#to_a;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"6Returns a new 6-element array, consisting of the ;TI"7label, user CPU time, system CPU time, children's ;TI";user CPU time, children's system CPU time and elapsed ;TI"real time.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI"Tms;TcRDoc::NormalClass00Tms/new-c.ri000064400000001146152375457100006667 0ustar00U:RDoc::AnyMethod[iI"new:ETI"Benchmark::Tms::new;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"1Returns an initialized Tms object which has ;TI"C+utime+ as the user CPU time, +stime+ as the system CPU time, ;TI"J+cutime+ as the children's user CPU time, +cstime+ as the children's ;TI"Osystem CPU time, +real+ as the elapsed real time and +label+ as the label.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I"T(utime = 0.0, stime = 0.0, cutime = 0.0, cstime = 0.0, real = 0.0, label = nil);T@FI"Tms;TcRDoc::NormalClass00Tms/%2a-i.ri000064400000000600152375457100006445 0ustar00U:RDoc::AnyMethod[iI"*:ETI"Benchmark::Tms#*;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DReturns a new Tms object obtained by memberwise multiplication ;TI"8of the individual times for this Tms object by _x_.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I"(x);T@FI"Tms;TcRDoc::NormalClass00Tms/label-i.ri000064400000000422152375457100007157 0ustar00U:RDoc::Attr[iI" label:ETI"Benchmark::Tms#label;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I" Label;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/%2f-i.ri000064400000000670152375457100006461 0ustar00U:RDoc::AnyMethod[iI"/:EFI"Benchmark::Tms#/;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I">Returns a new Tms object obtained by memberwise division ;TI"9of the individual times for this Tms object by _x_. ;TI";This method and #+() are useful for taking statistics.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I"(x);T@FI"Tms;TcRDoc::NormalClass00Tms/cstime-i.ri000064400000000452152375457100007367 0ustar00U:RDoc::Attr[iI" cstime:ETI"Benchmark::Tms#cstime;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I" System CPU time of children;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/memberwise-i.ri000064400000001110152375457100010232 0ustar00U:RDoc::AnyMethod[iI"memberwise:EFI"Benchmark::Tms#memberwise;TF:protectedo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"DReturns a new Tms object obtained by memberwise operation +op+ ;TI"Iof the individual times for this Tms object with those of the other ;TI"Tms object.;To:RDoc::Markup::BlankLineo; ; [I"J+op+ can be a mathematical operation such as +, -, ;TI"*, /;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I" (op, x);T@FI"Tms;TcRDoc::NormalClass00Tms/to_s-i.ri000064400000000434152375457100007047 0ustar00U:RDoc::AnyMethod[iI" to_s:EFI"Benchmark::Tms#to_s;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Same as #format.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I"();T@FI"Tms;TcRDoc::NormalClass00Tms/add-i.ri000064400000000643152375457100006635 0ustar00U:RDoc::AnyMethod[iI"add:EFI"Benchmark::Tms#add;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LReturns a new Tms object whose times are the sum of the times for this ;TI"JTms object, plus the time required to execute the code block (+blk+).;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I";T[I"();T@FI"Tms;TcRDoc::NormalClass00Tms/cdesc-Tms.ri000064400000002235152375457100007500 0ustar00U:RDoc::NormalClass[iI"Tms:ETI"Benchmark::Tms;TI" Object;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"GA data object, representing the times associated with a benchmark ;TI"measurement.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0; 0; 0[ [ I" cstime;TI"R;T: publicFI"lib/benchmark.rb;T[ I" cutime;TI"R;T; F@[ I" label;TI"R;T; F@[ I" real;TI"R;T; F@[ I" stime;TI"R;T; F@[ I" total;TI"R;T; F@[ I" utime;TI"R;T; F@[U:RDoc::Constant[iI" CAPTION;FI"Benchmark::Tms::CAPTION;T00o;;[o; ;[I"1Default caption, see also Benchmark::CAPTION;T; @; 0@@cRDoc::NormalClass0U; [iI" FORMAT;FI"Benchmark::Tms::FORMAT;T00o;;[o; ;[I"6Default format string, see also Benchmark::FORMAT;T; @; 0@@@40[[[I" class;T[[; [[I"new;T@[:protected[[: private[[I" instance;T[[; [[I"*;T@[I"+;T@[I"-;T@[I"/;F@[I"add;F@[I" add!;F@[I" format;F@[I" to_a;F@[I" to_s;F@[;[[I"memberwise;F@[;[[[U:RDoc::Context::Section[i0o;;[; 0; 0[@I"Benchmark;FcRDoc::NormalModuleTms/total-i.ri000064400000000510152375457100007221 0ustar00U:RDoc::Attr[iI" total:ETI"Benchmark::Tms#total;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"@Total time, that is +utime+ + +stime+ + +cutime+ + +cstime+;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/real-i.ri000064400000000434152375457100007026 0ustar00U:RDoc::Attr[iI" real:ETI"Benchmark::Tms#real;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"Elapsed real time;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/%2b-i.ri000064400000000740152375457100006453 0ustar00U:RDoc::AnyMethod[iI"+:ETI"Benchmark::Tms#+;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I"?Returns a new Tms object obtained by memberwise summation ;TI"Iof the individual times for this Tms object with those of the other ;TI"Tms object. ;TI";This method and #/() are useful for taking statistics.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I" (other);T@FI"Tms;TcRDoc::NormalClass00Tms/%2d-i.ri000064400000000644152375457100006460 0ustar00U:RDoc::AnyMethod[iI"-:ETI"Benchmark::Tms#-;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"AReturns a new Tms object obtained by memberwise subtraction ;TI"Iof the individual times for the other Tms object from those of this ;TI"Tms object.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I" (other);T@FI"Tms;TcRDoc::NormalClass00Tms/utime-i.ri000064400000000432152375457100007224 0ustar00U:RDoc::Attr[iI" utime:ETI"Benchmark::Tms#utime;TI"R;T: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"User CPU time;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below0F@I"Benchmark::Tms;TcRDoc::NormalClass0Tms/add%21-i.ri000064400000000454152375457100007045 0ustar00U:RDoc::AnyMethod[iI" add!:EFI"Benchmark::Tms#add!;TF: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"!An in-place version of #add.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below000[I" (&blk);T@FI"Tms;TcRDoc::NormalClass00bm-c.ri000064400000002076152375457100005734 0ustar00U:RDoc::AnyMethod[iI"bm:EFI"Benchmark::bm;TT: publico:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"KA simple interface to the #benchmark method, #bm generates sequential ;TI"Greports with labels. The parameters have the same meaning as for ;TI"#benchmark.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"require 'benchmark' ;TI" ;TI"n = 5000000 ;TI"Benchmark.bm(7) do |x| ;TI": x.report("for:") { for i in 1..n; a = "1"; end } ;TI": x.report("times:") { n.times do ; a = "1"; end } ;TI": x.report("upto:") { 1.upto(n) do ; a = "1"; end } ;TI" end ;T: @format0o; ; [I"Generates:;T@o; ; [ I": user system total real ;TI";for: 0.960000 0.000000 0.960000 ( 0.957966) ;TI";times: 0.960000 0.000000 0.960000 ( 0.960423) ;TI":upto: 0.950000 0.000000 0.950000 ( 0.954864);T; 0: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I" report;F[I"(label_width = 0, *labels);T@$FI"Benchmark;FcRDoc::NormalModule00realtime-i.ri000064400000000533152375457100007142 0ustar00U:RDoc::AnyMethod[iI" realtime:EFI"Benchmark#realtime;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"CReturns the elapsed real time used to execute the given block.;T: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I";T[I"();T@FI"Benchmark;FcRDoc::NormalModule00bmbm-i.ri000064400000003550152375457100006257 0ustar00U:RDoc::AnyMethod[iI" bmbm:EFI"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"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;F[I"(width = 0);T@7FI"Benchmark;FcRDoc::NormalModule00benchmark-c.ri000064400000004050152375457100007262 0ustar00U:RDoc::AnyMethod[iI"benchmark:EFI"Benchmark::benchmark;TT: publico:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [ I">Invokes the block with a Benchmark::Report object, which ;TI"Dmay be used to collect and report on the results of individual ;TI"@benchmark tests. Reserves +label_width+ leading spaces for ;TI"=labels on each line. Prints +caption+ at the top of the ;TI"4report, and uses +format+ to format each line. ;TI"0Returns an array of Benchmark::Tms objects.;To:RDoc::Markup::BlankLineo; ; [ I"&If the block returns an array of ;TI":Benchmark::Tms objects, these will be used to format ;TI";additional lines of output. If +label+ parameters are ;TI"6given, these are used to label these extra lines.;T@o; ; [I"L_Note_: Other methods provide a simpler interface to this one, and are ;TI"Msuitable for nearly all benchmarking requirements. See the examples in ;TI".Benchmark, and the #bm and #bmbm methods.;T@o; ; [I" Example:;T@o:RDoc::Markup::Verbatim; [I"require 'benchmark' ;TI"Kinclude Benchmark # we need the CAPTION and FORMAT constants ;TI" ;TI"n = 5000000 ;TI"HBenchmark.benchmark(CAPTION, 7, FORMAT, ">total:", ">avg:") do |x| ;TI"? tf = x.report("for:") { for i in 1..n; a = "1"; end } ;TI"? tt = x.report("times:") { n.times do ; a = "1"; end } ;TI"? tu = x.report("upto:") { 1.upto(n) do ; a = "1"; end } ;TI" [tf+tt+tu, (tf+tt+tu)/3] ;TI" end ;T: @format0o; ; [I"Generates:;T@o; ; [ I": user system total real ;TI";for: 0.970000 0.000000 0.970000 ( 0.970493) ;TI";times: 0.990000 0.000000 0.990000 ( 0.989542) ;TI";upto: 0.970000 0.000000 0.970000 ( 0.972854) ;TI";>total: 2.930000 0.000000 2.930000 ( 2.932889) ;TI":>avg: 0.976667 0.000000 0.976667 ( 0.977630);T; 0: @fileI"lib/benchmark.rb;T:0@omit_headings_from_table_of_contents_below00I" report;F[I"=(caption = "", label_width = nil, format = nil, *labels);T@9FI"Benchmark;FcRDoc::NormalModule00