Ruby Benchmark Functions

EditRocket provides the following information on Benchmark functions in the Ruby source code builder.

benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) - Invokes the block with a Benchmark::Report object, which may be used to collect and report on the results of individual benchmark tests. Reserves label_width leading spaces for labels on each line. Prints caption at the top of the report, and uses fmt to format each line. If the block returns an array of Benchmark::Tms objects, these will be used to format additional lines of output. If label parameters are given, these are used to label these extra lines.

bm(label_width = 0, *labels) - "A simple interface to the #benchmark method, #bm is generates sequential reports with labels. The parameters have the same meaning as for #benchmark."

bmbm(width = 0) - "Sometimes benchmark results are skewed because code executed earlier encounters different garbage collection overheads than that run later. #bmbm attempts to minimize this effect by running the tests twice, the first time as a rehearsal in order to get the runtime environment stable, the second time for real. GC.start is executed before the start of each of the real timings; the cost of this is not included in the timings. In reality, though, there's only so much that #bmbm can do, and the results are not guaranteed to be isolated from garbage collection and other effects."

measure(label = "") - Returns the time used to execute the given block as a Benchmark::Tms object.

realtime() - Returns the elapsed real time used to execute the given block.