Skip to content

Commit ba69439

Browse files
tenta4oberpar
authored andcommitted
lcov: Make JSON module configurable
lcov 1.15 uses core module JSON::PP for parsing gcov-9 output. This slowed down analysis for my project 10 times (with GCC 5 they uses txt format). My changes add an option to configure JSON module for lcov. To reach past performance I can force lcov to use fast JSON::XS module, e.g.: $ lcov --capture --directory $products --output-file $file --rc lcov_json_module=JSON::XS As this is not a Perl core module you should install it by yourself: $ cpan JSON:XS Regarding performance, here is execution time for a specific file: JSON::PP (default): 0m10.764s JSON::XS : 0m0.542s Cpanel::JSON::XS : 0m0.618s No JSON (GCC 5) : 0m0.444s [oberpar: added verbose commit log from pull request, fixed typos, renamed rc option to lcov_* to make it more versatile] Signed-off-by: Odinochenko Aleksey <[email protected]>
1 parent 462f71d commit ba69439

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bin/geninfo

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ use Getopt::Long;
6060
use Digest::MD5 qw(md5_base64);
6161
use Cwd qw/abs_path/;
6262
use IO::Uncompress::Gunzip qw(gunzip $GunzipError);
63-
use JSON::PP qw(decode_json);
6463

6564
if( $^O eq "msys" )
6665
{
@@ -275,6 +274,7 @@ our $br_coverage = 0;
275274
our $no_exception_br = 0;
276275
our $rc_auto_base = 1;
277276
our $rc_intermediate = "auto";
277+
our $rc_json_module = "auto";
278278
our $intermediate;
279279
our $excl_line = "LCOV_EXCL_LINE";
280280
our $excl_br_line = "LCOV_EXCL_BR_LINE";
@@ -345,6 +345,7 @@ if ($config || %opt_rc)
345345
"geninfo_adjust_src_path" => \$rc_adjust_src_path,
346346
"geninfo_auto_base" => \$rc_auto_base,
347347
"geninfo_intermediate" => \$rc_intermediate,
348+
"lcov_json_module" => \$rc_json_module,
348349
"geninfo_no_exception_branch" => \$no_exception_br,
349350
"lcov_function_coverage" => \$func_coverage,
350351
"lcov_branch_coverage" => \$br_coverage,
@@ -493,6 +494,18 @@ if ($rc_intermediate eq "0") {
493494
"'$rc_intermediate'\n");
494495
}
495496

497+
# Determine JSON module
498+
my $current_json_module = "JSON::PP";
499+
if ($rc_json_module ne "auto") {
500+
$current_json_module = $rc_json_module
501+
}
502+
503+
use Module::Load;
504+
eval "load $current_json_module, 'decode_json'";
505+
if ($@) {
506+
die("Module is not installed: ". "'$current_json_module'\n");
507+
};
508+
496509
if ($intermediate) {
497510
info("Using intermediate gcov format\n");
498511
if ($opt_derive_func_data) {

0 commit comments

Comments
 (0)