profile

Posted by keming on July 14, 2021

gperftools/suncollector

  • suncollect
    • https://docs.oracle.com/cd/E77782_01/html/E77785/gozsw.html#scrolltoc

    • gperftools

      • 万能的官方文档,可以不做侵入式的修改https://github.com/gperftools/gperftools

        • env LD_PRELOAD=/usr/local/lib/libtcmalloc.so output/bin/west xxx
          
      • https://blog.csdn.net/weixin_41376894/article/details/78793321

      • target_link_libraries(west PRIVATE
        	...
        	profiler
        )
               
        #include "gperftools/profiler.h"
               
        ProfilerStart("./kem.prof");
        ProfilerStop();
               
        pprof output/bin/west kem.prof --pdf > kem_prof.pdf
        // 转pdf的ps2pdf找不到,可以yum install ghostscript
        
      • gperftools还可用做memory heap的分析,再link一个tcmalloc就可以

      • https://daiwk.github.io/posts/knowledge-gperftools.html

valgrind

  • valgrind 相当不好用啊
  • https://www.cnblogs.com/developing/articles/10979109.html
  • valgrind –tool=memcheck –leak-check=full ./test

ASan

  • Address Sanitizer,比valgrind速度快,g++ 4.8之后就可以用了
  • https://www.jianshu.com/p/3a2df9b7c353

memory profile各种工具的对比

打印内存

  • 其他文章有写