How can I speed up line by line reading of an ASCII file? (C++)

前端 未结 9 981
夕颜
夕颜 2020-12-30 08:02

Here\'s a bit of code that is a considerable bottleneck after doing some measuring:

//-----------------------------------------------------------------------         


        
9条回答
  •  清歌不尽
    2020-12-30 08:33

    A proper implementation of the IO library would cache the data for you, avoiding excessive disk accesses and system calls. I recommend that you use a system-call level tool (e.g. strace if you're under Linux) to check what actually happens with your IO.

    Obviously, dict.insert(xxx) could also be a nuisance if it doesn't allow O(1) insertion.

提交回复
热议问题