I adapted this right out of the book (ed 2 pg 665)

start = DateTime.now

 <thing you want to time>           

stop = DateTime.now

diff = stop - start             

h,m,s,frac = Date.day_fraction_to_time(diff)

s += frac.to_f

puts "That's #{h} Hours, #{m} Minutes, #{s} Seconds"


Output: That's 4 Minutes, 8.00000270833333 Seconds

Hope this helps,

--Mark
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tuyet
Cong-Ton-Nu
Sent: Monday, July 18, 2005 7:42 PM
To: '[email protected]'
Subject: [Wtr-general] Calculating Elapsed Time

I have this routine that calculates starting time and finished time, but
I
can't figure out how to get the Elapsed time (finished time - starting
time).
I messed around with all sorts of permutations, but kept getting "0.00".
Any suggestion is appreciated, thanks:

require 'test/unit' 
require 'test/unit/ui/console/testrunner'
require 'watir/windowhelper'

require 'login.rb' #this is your test case file

MAX_ITERATIONS = 1

result = Test::Unit::TestResult.new


MAX_ITERATIONS.times do
    sleep 3
    TC_Login.suite.run(result) do |s, name| 
        puts "Status=#{s} and name = #{name}"
        time = Time.now.strftime("%m %d %Y %H %M %S") 
        puts "Time(MMDDYYYYhhmmss=#{time}"
    end    
    puts result.to_s
    puts result.failure_count
    
    

   
end

exit!
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to