General strategies for memory/speed problems

后端 未结 4 1775
春和景丽
春和景丽 2021-01-21 23:05

I have a c++ code which runs through about 200 ASCII files, does some basic data processing, and outputs a single ASCII file with (basically) all of the data.

The progra

4条回答
  •  孤独总比滥情好
    2021-01-21 23:52

    Analyze your code with callgrind, part of the valgrind suite. You can graphically browse the results with kcachegrind. (Despite its name, it works on callgrind output too.) It's free and will give you awesome detail.

    You can also externally turn data collection off and on. So start with it off, wait until your program gets slow, turn it on during the problem time, then turn it off. You'll see where the CPU was going. If necessary, do the same thing in reverse watching only when it's fast and compare.

    Usually, the problem will stick out like a sore thumb.

提交回复
热议问题