To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 14546
14545  |  14547
Subject: 
Re: how does a line ends?
Newsgroups: 
lugnet.cad
Date: 
Mon, 9 Apr 2007 22:00:49 GMT
Viewed: 
2201 times
  
In lugnet.cad, Travis Cobbs wrote:
   In lugnet.cad, Ross Crawford wrote:
   Google to the rescue.

Thanks, ROSCO. I took that code and modified it to use char instead of _TCHAR, and got timings of 720-750ms, compared to the 750-780ms I got with my original one. I then modified it to support CR and LF interchangeably, and got back to the 750-780ms timings from my original code. So it seems safe to say that the actual MS fgets function is done differently. (The one you posted is for _TCHAR, which is two bytes when UNICODE is defined, and one byte when UNICODE isn’t defined.)

Now that I’m at work, I’m able to look at Microsoft’s implementation of fgets for Visual Studio 2005. They do a lock on the file prior to their loop, then call _fgetc_nolock to get each character, instead of fgetc or fread. (That’s an MS-specific function, obviously.) This means that there’s no locking overhead involved in each character read, and I’m guessing that’s what provides the performance boost. Normally each call to fgetc or fread would require a lock/unlock.

--Travis



Message is in Reply To:
  Re: how does a line ends?
 
(...) Thanks, ROSCO. I took that code and modified it to use char instead of _TCHAR, and got timings of 720-750ms, compared to the 750-780ms I got with my original one. I then modified it to support CR and LF interchangeably, and got back to the (...) (18 years ago, 7-Apr-07, to lugnet.cad, FTX)

24 Messages in This Thread:











Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR