2015-10-20 82 views

回答

2

使用锵和LLVM-profdata

参观锵用户手册profile with instrumentation

LLVM DOC llvm-profdata

总结:

  1. 构建代码的仪表版

    clang -O2 -fprofile-instr-generate code.c 
    
  2. 运行插桩的可执行文件获取配置文件数据文件

    ./a.out 
    
  3. 合并多个运行配置文件,并通过运行

    llvm-profdata merge *.profraw -output=code.profdata 
    
  4. 构建代码再次

    clang -O2 -fprofile-instr-use=code.profdata code.c 
    
  5. 格式化文件

(可选?)5.显示此文件和任何指定功能的配置文件计数器

llvm-profdata show -all-functions code.profdata