Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
How to time the duration of a script.
Oscar Gonzalez
12/12/2005 10:53:00 PM
If I wanted to find something like the "time" feature on shell...
where you can do:
time ls
and it will tell you how long it took to execute...
How would I do this in Ruby or what is the packaged that can do this for
me? I want it to kick off as soon as the script gets called and just
print the time taken to execute at the end of the script.
--
Posted via
http://www.ruby-...
.
2 Answers
Eero Saynatkari
12/12/2005 10:59:00 PM
0
Oscar Gonzalez wrote:
> If I wanted to find something like the "time" feature on shell...
>
> where you can do:
>
> time ls
>
> and it will tell you how long it took to execute...
>
> How would I do this in Ruby or what is the packaged that can do this for
> me? I want it to kick off as soon as the script gets called and just
> print the time taken to execute at the end of the script.
Well, you can actually use 'time my.rb' :)
Within ruby, you can use Benchmark (in stdlib):
require 'benchmark'
Benchmark.bm {|bench|
bench.report { do_something_here }
}
Another popular idiom seems to be the classic:
start = Time.now
# Do something
duration = Time.now - start
E
--
Posted via
http://www.ruby-...
.
Ara.T.Howard
12/12/2005 11:29:00 PM
0
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
How to time the duration of a script.
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password