Mail Archives: djgpp/2001/06/13/19:45:05
Mon, 11 Jun 2001, DJ Delorie <dj AT delorie DOT com> wrote:
>> Is DOS _really_ so slow?
DD> No, but consider that Unix keeps track of the time *as* a time_t, so
DD> time() merely reads a number from memory and returns it - a few CPU
DD> cycles at best. DOS, however, uses the hardware realtime clock, so it
DD> must convert month/day/year/hour/minute/second/timezone to a time_t
DD> each time you need to know what time it is. The conversion is slow.
Well, but why time() simply not caches this values (month/day/year/
hour/minute/second/timezone) (such as Linux kernel does)? If time() will
remember old values of year, month, day and timezone, it will works many
times faster (it'll needs only to add sec+60*(min+60*hour)).
I've tested mktime()'s speed just now and yes, you are right.
mktime() is a bottle-neck of the time(). It takes about 70-80% of the
time()'s time :)
- Raw text -