[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 17:16:52 +0100

Greg Stein wrote:
> On Mon, Oct 26, 2009 at 08:32, Branko Cibej <brane_at_xbc.nu> wrote:
>
>>> 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?
>

Eh, you have a point. Premature optimization blues. Pity it can't format
microseconds directly, though ... but it appears to me that if we use
datetime, one can just do:

    import datetime
    start_time = datetime.datetime.now()
    # ...
    elapsed_time = str(datetime.datetime.now() - start_time)

that won't zero-pad the hours, and will print microseconds instead of
milliseconds; but surely that shouldn't be a problem as far as parsing
the time for JUnit is concerned, yes?

-- Brane

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2411430
Received on 2009-10-26 17:17:36 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.