bm(label_width = 0, *labels) {|report| ...} in Ruby

By: Jeya Emailed: 1696 times Printed: 2196 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

A simple interface to the benchmark method, bm is generates sequential reports with labels. The parameters have the same meaning as for benchmark.

    require 'benchmark'

    n = 50000
    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:     1.050000   0.000000   1.050000 (  0.503462)
       times:   1.533333   0.016667   1.550000 (  0.735473)
       upto:    1.500000   0.016667   1.516667 (  0.711239)

Ruby Home | All Ruby Tutorials | Latest Ruby Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Jeya
FTP using Ruby
Security in dRuby
Using remote objects under dRuby
bmbm(width = 0) {|job| ...} in Ruby
bm(label_width = 0, *labels) {|report| ...} in Ruby
benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby

More Tutorials in Ruby
Standard Library Packages in Ruby
Module Abbrev in Ruby
encoding and decoding in Ruby using Base64 Module
Benchmark module in Ruby
benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby
bm(label_width = 0, *labels) {|report| ...} in Ruby
bmbm(width = 0) {|job| ...} in Ruby
CGI class in Ruby
URL encode a string in Ruby
escapeElement() in Ruby
escapeHTML() in Ruby
new(type = "query") in Ruby
parse(query) in Ruby
pretty() in Ruby
Format a Time object as a String in Ruby

More Latest News
Most Viewed Articles (in Ruby )
encoding and decoding in Ruby using Base64 Module
URL encode a string in Ruby
Methods in Ruby on rails
Module Abbrev in Ruby
benchmark(caption = "", label_width = nil, fmtstr = nil, *labels) {|report| ...} in Ruby
bm(label_width = 0, *labels) {|report| ...} in Ruby
bmbm(width = 0) {|job| ...} in Ruby
escapeElement() in Ruby
IMAP in Ruby
Getting started with Ruby on rails
Prompts, Command Lines, Prompts, and irb in Ruby on rails
Naming conventions in Ruby on rails
Command-line Arguments in Ruby on rails
if . . . elsif . . . else in Ruby on rails
unless in Ruby on rails
Most Emailed Articles (in Ruby)
parse(query) in Ruby
Sending emails using SMTP in Ruby
Defining tables and classes (using MySQL) in Ruby on Rails
Action Pack - Ruby On rails from request to response
unless in Ruby on rails
escapeHTML() in Ruby
SimpleDelegator in Ruby
Reading URL content using Ruby (HTTP)
POST a form in Ruby
IMAP in Ruby
Getting started with Ruby on rails
Naming conventions in Ruby on rails
if . . . elsif . . . else in Ruby on rails
The Question Mark Operator in Ruby on rails
URL encode a string in Ruby