Click here to Skip to main content
14,266,079 members

C / C++ / MFC

 
GeneralRe: _findfirst and fopen very slow Pin
leon de boer1-Feb-19 4:42
memberleon de boer1-Feb-19 4:42 
GeneralRe: _findfirst and fopen very slow Pin
Stefan_Lang1-Feb-19 4:59
memberStefan_Lang1-Feb-19 4:59 
GeneralRe: _findfirst and fopen very slow Pin
cristiapi1-Feb-19 5:44
membercristiapi1-Feb-19 5:44 
GeneralRe: _findfirst and fopen very slow Pin
cristiapi1-Feb-19 6:24
membercristiapi1-Feb-19 6:24 
GeneralRe: _findfirst and fopen very slow Pin
leon de boer1-Feb-19 21:40
memberleon de boer1-Feb-19 21:40 
GeneralRe: _findfirst and fopen very slow Pin
cristiapi1-Feb-19 23:35
membercristiapi1-Feb-19 23:35 
GeneralRe: _findfirst and fopen very slow Pin
leon de boer2-Feb-19 0:33
memberleon de boer2-Feb-19 0:33 
AnswerRe: _findfirst and fopen very slow Pin
Stefan_Lang31-Jan-19 21:27
memberStefan_Lang31-Jan-19 21:27 
I suspect that the reason for your program to run much faster on the second run is that modern drives cache a certain amount of data, and therefore don't need to rely on slow hardware for repeatedly reading the same files.

In your code, you read from each file line by line. Internally, these reads will trigger a request to read some block (or multiple blocks) of data. While each of these blocks is probably cached to be used for consecutive reads, any read request requiring a new block will cause another, slow, access to the hard disk.

You could speed this up by reading the whole file in a single operation: query its size, allocate a sufficiently large buffer, open as binary, and read the whole file into that buffer. Then your internal while loop can request each line from that buffer, which should be considerably faster.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

AnswerRe: _findfirst and fopen very slow Pin
Joe Woodbury1-Feb-19 5:36
professionalJoe Woodbury1-Feb-19 5:36 
AnswerRe: _findfirst and fopen very slow Pin
cristiapi2-Feb-19 1:13
membercristiapi2-Feb-19 1:13 
Questionwrite in .xlsx extension excel file using c++ Pin
Member 1413460229-Jan-19 23:49
memberMember 1413460229-Jan-19 23:49 
AnswerRe: write in .xlsx extension excel file using c++ Pin
Richard MacCutchan29-Jan-19 23:52
protectorRichard MacCutchan29-Jan-19 23:52 
AnswerRe: write in .xlsx extension excel file using c++ Pin
leon de boer30-Jan-19 2:09
memberleon de boer30-Jan-19 2:09 
RantC++ Typedefs Pin
nitrous_00729-Jan-19 4:45
membernitrous_00729-Jan-19 4:45 
GeneralRe: C++ Typedefs Pin
Richard MacCutchan29-Jan-19 5:41
protectorRichard MacCutchan29-Jan-19 5:41 
GeneralRe: C++ Typedefs Pin
David Crow29-Jan-19 6:20
memberDavid Crow29-Jan-19 6:20 
GeneralRe: C++ Typedefs Pin
Joe Woodbury29-Jan-19 9:45
professionalJoe Woodbury29-Jan-19 9:45 
GeneralRe: C++ Typedefs Pin
CPallini29-Jan-19 10:35
mveCPallini29-Jan-19 10:35 
GeneralRe: C++ Typedefs Pin
Stefan_Lang29-Jan-19 21:16
memberStefan_Lang29-Jan-19 21:16 
GeneralRe: C++ Typedefs Pin
leon de boer30-Jan-19 3:20
memberleon de boer30-Jan-19 3:20 
QuestionWhere do you place your #includes? Pin
den2k8828-Jan-19 23:49
professionalden2k8828-Jan-19 23:49 
AnswerRe: Where do you place your #includes? Pin
Daniel Pfeffer29-Jan-19 0:32
professionalDaniel Pfeffer29-Jan-19 0:32 
GeneralRe: Where do you place your #includes? Pin
den2k8829-Jan-19 21:12
professionalden2k8829-Jan-19 21:12 
AnswerRe: Where do you place your #includes? Pin
speedbump9929-Jan-19 2:27
memberspeedbump9929-Jan-19 2:27 
GeneralRe: Where do you place your #includes? Pin
den2k8829-Jan-19 21:10
professionalden2k8829-Jan-19 21:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.