This is totaly non game related, but ...
I wrote a program in C++ to process a certain text file. When I only had 200 records it took 12 seconds. Not bad i thought, but then i tried 400 records... 96 seconds. 800 records took over 400 seconds and 1600 records was well in the thousands. I narrowed the code down to the point where I was just opening the file and dumping the whole thing onto the heap and then looping through it with a very simple "for" loop. In otherwords, i stripped out all processing code. The results where about the same.
So my question is then, why does the computer need an exponentialy longer time to deal with larger memory allocations? Could it be that my "for" loop used strlen?
for(unsigned long i = 0; i <= std::strlen(fileBuffer); i++){
}
Does strlen take much longer to return the length of a buffer that is a quite large? Some of these records where hundreds of bytes so the allocated memory was pretty big.
As i'm writing this i'm starting to think that it would have been much better to write...
unsigned long bufferSize = std::strlen(fileBuffer);
for(unsigned long i = 0; i <= bufferSize; i++){
}
~ChaosBob
(who probably just answered his own question)
Edited by - chaosbob on February 24, 2002 8:03:53 AM