I've been informed that my library is slower than it should be, on the order of 30+ times too slow parsing a particular file (text file, size 326 kb). The user suggested that it may be that I'm using std::ifstream
(presumably instead of FILE
).
I'd rather not blindly rewrite, so I thought I'd check here first, since my guess would be the bottleneck is elsewhere. I'm reading character by character, so the only functions I'm using are get()
, peek()
, and tellg()/seekg()
.
Update:
I profiled, and got confusing output - gprof didn't appear to think that it took so long. I rewrote the program to read the entire file into a buffer first, and it sped up by about 100x. I think the problem may have been the tellg()/seekg()
that took a long time, but gprof may have been unable to see that for some reason. In any case, ifstream
does not appear to buffer the entire file, even for this size.