Measure time in Ruby -


How can I measure the time taken by a method and individual statements in that method in Ruby? If you are looking at the method below, then I want to reuse the total time taken by law and the time and access taken for database access. Before every statement I do not want to write the benchmark. Does the Rabbi interpreter give us a hook to do this?

  to use df foo # code to code # code to reuse the database. End    

You can use the time object ( )

For example,

  start = time.now # time to end the code = time.New diff = finish - start   < 

Edit: Expiration is reserved.

/ html>

Comments