[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] Include milliseconds in test report

From: Branko Cibej <brane_at_xbc.nu>
Date: Mon, 26 Oct 2009 13:32:38 +0100

Bhuvaneswaran A wrote:
> On Mon, 2009-10-26 at 11:38 +0100, Branko Čibej wrote:
>
>> "As discussed", yes; but I don't believe this will account for the
>> discrepancy between wall clock time and reported test execution time,
>> also "as discussed". :)
>>
>
> Yes; refer to my reply to another email thread for reasons that is
> contributing to this discrepancy.
>
>
>>> Index: build/run_tests.py
>>> =======================================
>>> --- build/run_tests.py (revision 40220)
>>> +++ build/run_tests.py (working copy)
>>> @@ -270,8 +270,14 @@
>>> log.write('FAIL: %s: Unknown test failure.\n' % progbase)
>>> # Log the elapsed time.
>>> - elapsed_time = time.strftime('%H:%M:%S',
>>> - time.gmtime(time.time() - start_time))
>>> + test_time = time.time() - start_time
>>> + elapsed_time = time.strftime('%H:%M:%S', time.gmtime(test_time))
>>> +
>>> + # certain system clock may not provide fractions of second
>>> + if str(test_time).find('.') == -1:
>>> + elapsed_time += '.00'
>>> + else:
>>> + elapsed_time += '.' + str(test_time).split('.')[1]
>>> log.write('END: %s\n' % progbase)
>>> log.write('ELAPSED: %s %s\n' % (progbase, elapsed_time))
>>> log.write('\n')
>>>
>> Uh. Why don't you just format in the milliseconds in strftime? The
>> Python documentation is your friend. Who cares if the system clock
>> isn't
>> precise enough -- you'll just get the zeros there from strftime
>> instead.
>> (And note that you need three digits, not two, to correctly represent
>> milliseconds.)
>>
>
> AFAIK, srrftime() does not seem to support milliseconds.

[...] Oh duh! Sorry, I mixed up my modules. No, i don't think it makes
sense to use datetime just for this. I'd do something like the following:

    elapsed_time = time.strftime('%H:%M:%S.%%03d', time.gmtime(test_time)) % \
                   math.floor(0.5 + 1000 * math.modf(test_time)[0])

and don't forget to "import math"

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2411367
Received on 2009-10-26 13:32:59 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.