Having been lately using Time::HiRes to time events in a program, like
the time it takes a nonblocking socket to connect(). The problem with
Time::HiRes's values is that they're stored in doubles, which lose their
precision very quickly if you take two large numbers (say, epoch
timestamps) and try to subtract them.
To solve this problem, I wrote a little object class that tracks seconds
and microseconds in two integer fields, and retains full microsecond
precision over addition and subtraction operators, as well as having
transparent to/from decimal strings conversion.
I've put the code here, for now:
http://www.leonerd.org.uk/code/perl/TimeVal.html (POD)
http://www.leonerd.org.uk/code/perl/TimeVal.pm (code)
I was going to find a nice CPAN name for it and upload it there, but then
I thought that surely there must already exist some code to do this. I've
had a good search around and can't find anything similar.
Before I go uploading this - is anyone aware of anything similar?
--
Paul "LeoNerd" Evans
leonerd@xxxxxxxxxxxxxx
ICQ# 4135350 | Registered Linux# 179460
http://www.leonerd.org.uk/
signature.asc
Description: PGP signature
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|