Linux C 程序性能测试 valgrind callgrind分析函数耗时、perf分析函数CPU消耗
利用valgrindcallgrind分析函数时间消耗(尤其在有网络、磁盘等有IO操作下,分析调用时间。在被IO阻塞情况下,不会明显占用CPU资源)编写测试程序#include#includevoidperf1(){unsignedinti=0;while(i<200){intb=i++;}usleep(10);}voidperf(){inti=0;while(i++<100000){intb=i