Mail Archives: djgpp/2001/06/11/19:47:33
Wed, 6 Jun 2001, Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
>>        But IMHO djgpp works better under windoze dos session, not under 
>> dosemu :(, isn't it? 
EZ> I wasn't thinking about DOSEmu.
   So, Win9x DOS box is the best environment for DJGPP, isn't it?
>> Why time() is so _incredible_ slow? 100 000 calls of dj's time() takes 
>> about 4-5 seconds on the my Cel900 (win95osr2)! I thinked that 
>> this is because time() is so complex but under linux (glibc 2.1)
>> about 10 000 000(!) time() calls also takes about 3-4 seconds...
>> So djgpp's time() is about 100 times slower than linux's time() :(.
EZ> If you look into the sources, you will see that the DJGPP version calls 
EZ> DOS (twice) to get the system date and time.  Calling a real-mode 
EZ> interrupt from a protected-mode program has a huge overhead, due to the 
EZ> need to switch the CPU from protected to real mode and back.
   Yes, sources looks pretty simple - there are two calls of int21 and
a small piece of code...
   I've tested time() speed with Borland C++ and it's about 3 times faster
than dj's version. But is is slow anyway if I compare it with Linux... :(
Is DOS _really_ so slow?
>>     I has been forced to use clock() (which works fast) instead of time()
>> because I need to call it many times...
EZ> Why do you need to call `time' many times?  It's unusual that a program 
EZ> should need that.
   Do you know a _portable_ way to check timeouts? Time() (or gettimeofday())
is portable and fast (under Linux, for example ;). So, program looks 
like this:
--------------------------------------------------
while (!timeout()) {
   if (do_a_piece_of_work()==SUCCESS) break;
}
--------------------------------------------------
- Raw text -