[Quickfix-developers] Re: UtcTimeStamp implementation bugs
Brought to you by:
orenmnero
|
From: Caleb E. <cal...@gm...> - 2005-07-12 19:45:42
|
On 7/11/05, Caleb Epstein <cal...@gm...> wrote: > // mktime converts a struct tm (IN LOCAL TIME) to a time_t > time_t t =3D mktime( (tm*)this ); > // Converts a time_t back to a struct tm. Presumably this is done > // for normalization so that a user specifying a date of 31-02-2005 > // will end up with a more correct 02-03-2005? > *static_cast<tm*>(this) =3D time_localtime( &t ); [...] > My impression is that the mktime and localtime calls (the latter of > which is redundant - POSIX mktime modifies the passed-in struct tm in > place so you don't need to call localtime at all) are used only to > normalize values that might be specified incorrectly by the user (e.g. > February 30th or the like) Well, my impression was wrong :-) There is code in SessionTime which uses the tm_wday (via getWeekDay) so the call to mktime is necessary to populate this field, otherwise a couple of tests in SessionTimeTest.cpp suite fail. > But, because of their localtime semantics and the way that QuickFIX > populates the structures with GMT values, they actually cause breakage > in certain edge situations. These functions are also performance pigs > on some platforms (notably Solaris before Solaris 9) where I've seen > QuickFIX spend ~50% of its runtime in mktime calls. >=20 > For these reasons, I'm going to submit a patch that drops the > mktime/localtime usage (and some unncessary setCurrent calls) from the > UtcTimeStamp class which should end up giving a small performance > boost. Can anyone see a flaw in this analysis? My approach now is to completely replace the underpinnings of UtcTimeStamp and the related classes so they don't use "struct tm" at all, but instead store a double representing the Julian day number and the fractional portion of a day. This eliminates the need for a lot of the time-related system calls and static_cast<tm*> weirdness in many places. I'll send along the patch once I can get the code to stop failing the bulk of the tests :-) --=20 Caleb Epstein caleb dot epstein at gmail dot com |