我已经将构建环境编译器从gcc 5.5.0更新到了gcc 9.3.0,并注意到覆盖率计算性能回归。
它成为的10倍慢 (5小时vs 48小时整个项目)。
我的调查显示,在gcov-9中,他们开始使用json格式而不是intermediate text format格式。这减缓了中间gcov文件的创建和解析。
最起码的例子如下:
> time geninfo --gcov-tool gcov-5 test5/CPrimitiveLayerTest.cpp.gcno
Found gcov version: 5.5.0
Using intermediate gcov format
Processing test5/CPrimitiveLayerTest.cpp.gcno
Finished .info-file creation
real 0m0.351s
user 0m0.298s
sys 0m0.047s
> time geninfo --gcov-tool gcov-9 test9/CPrimitiveLayerTest.cpp.gcno
Found gcov version: 9.3.0
Using intermediate gcov format
Processing test9/CPrimitiveLayerTest.cpp.gcno
Finished .info-file creation
real 0m8.024s
user 0m7.929s
sys 0m0.084s我没有找到回到旧格式的方法,但可能有任何解决办法或补丁。
我知道gcov的论点--json-format,但是gcov 1.15可以处理json格式或所谓的intermediate text format。同时,gcov9可以输出json格式或所谓的logfile格式文件。
发布于 2020-12-09 12:39:20
进一步的研究表明,这是因为lcov 1.15使用JSON:PP模块进行json解析。将JSON:PP替换为JSON:XS (快速解析器)提供了所需的加速。
因此,我使用下面的命令来达到它:
# patch geninfo to use fast json parser
> sudo sed -i 's/use JSON::PP/use JSON::XS/g' /usr/local/bin/geninfo
# install perl module
> sudo cpan install JSON:XShttps://stackoverflow.com/questions/65204150
复制相似问题