Is std::ifstream significantly slower than FILE?

后端 未结 6 1821
余生分开走
余生分开走 2020-12-01 11:07

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 th

6条回答
  •  眼角桃花
    2020-12-01 12:08

    I agree that you should profile. But if you're reading the file a character at a time, how about creating a memory-mapped file? That way you can treat the file like an array of characters, and the OS should take care of all the low-level buffering for you. The simplest and probably fastest solution is a win in my book. :)

提交回复
热议问题