Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
basic millisecond code profile?
warhero
6/25/2007 8:21:00 PM
if I need to see the amount of milliseconds / seconds a method takes can
I do something like this:
class Person
attr_accessor :first
def pl
now = Time.now.usec #get milliseconds
0.upto(10000) do |i|
i = 'g'
end
now2 = Time.now.usec #get milliseconds
puts String(now2 - now)
end
end
p = Person.new
p.pl
whats the best way to do this?
--
Posted via
http://www.ruby-...
.
1 Answer
warhero
6/25/2007 8:21:00 PM
0
Aaron Smith wrote:
> if I need to see the amount of milliseconds / seconds a method takes can
> I do something like this:
>
> class Person
> attr_accessor :first
> def pl
> now = Time.now.usec #get milliseconds
> 0.upto(10000) do |i|
> i = 'g'
> end
> now2 = Time.now.usec #get milliseconds
> puts String(now2 - now)
> end
> end
> p = Person.new
> p.pl
>
> whats the best way to do this?
class Person
attr_accessor :first
def pl
now = Time.now.usec / 1000 #get milliseconds
0.upto(10000) do |i|
i = 'g'
end
now2 = Time.now.usec / 1000 #get milliseconds
puts String(now2 - now)
end
end
p = Person.new
p.pl
whoops, forgot the /1000
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
basic millisecond code profile?
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