On Mon, Oct 26, 2009 at 08:32, Branko Cibej <brane_at_xbc.nu> wrote:
> 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"
What? Something wrong with datetime, such that the math module is
better? If you gotta import one, then why not the one related to what
you're trying to do?
Cheers,
-g
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2411414
Received on 2009-10-26 16:25:52 CET