From: Daniel Stenberg Date: Sun, 13 Jul 2025 21:41:59 +0000 (+0200) Subject: top-complexity: also output average complexity X-Git-Tag: curl-8_15_0~25 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f5a44e154916bf3d287cc4c84d8263538405078d;p=thirdparty%2Fcurl.git top-complexity: also output average complexity Closes #17920 --- diff --git a/scripts/top-complexity b/scripts/top-complexity index 59629d9603..a5e3bc13b8 100755 --- a/scripts/top-complexity +++ b/scripts/top-complexity @@ -87,12 +87,14 @@ my $show = 65; my $error = 0; my %where; my %perm; +my $allscore = 0; +my $alllines = 0; # each line starts with the complexity score # 142 417 809 1677 1305 src/tool_getparam.c(1677): getparameter for my $l (@output) { chomp $l; - if($l =~/^(\d+)\t\d+\t\d+\t\d+\t\d+\t([^\(]+).*: ([^ ]*)/) { - my ($score, $path, $func)=($1, $2, $3); + if($l =~/^(\d+)\t\d+\t\d+\t\d+\t(\d+)\t([^\(]+).*: ([^ ]*)/) { + my ($score, $len, $path, $func)=($1, $2, $3, $4); if($score > $show) { my $allow = 0; @@ -106,6 +108,8 @@ for my $l (@output) { $error++; } } + $alllines += $len; + $allscore += ($len * $score); } } @@ -121,4 +125,6 @@ for my $e (sort {$where{$b} <=> $where{$a}} keys %where) { $perm{$e} ? " [ALLOWED]": ""; } +printf "\nAverage complexity: %.2f\n", $allscore / $alllines; + exit $error;