method
bm
Ruby latest stable (v2_5_5)
-
0 notes -
Class: Benchmark
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (-14)
- 2_2_9 (0)
- 2_4_6 (38)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
bm(label_width = 0, *labels)
public
A simple interface to the #benchmark method, #bm generates sequential reports with labels. label_width and labels parameters have the same meaning as for #benchmark.
require 'benchmark' n = 5000000 Benchmark.bm(7) do |x| x.report("for:") { for i in 1..n; a = "1"; end } x.report("times:") { n.times do ; a = "1"; end } x.report("upto:") { 1.upto(n) do ; a = "1"; end } end
Generates:
user system total real for: 0.960000 0.000000 0.960000 ( 0.957966) times: 0.960000 0.000000 0.960000 ( 0.960423) upto: 0.950000 0.000000 0.950000 ( 0.954864)