Skip to content

Commit 2dfafc9

Browse files
Peter Oberparleiteroberpar
authored andcommitted
genhtml: improve function table sorting
In the function table view, the initial view should show the functions sorted by execution count because - unlike with file names - the function name is not a natural order for functions (the line number would be, but that is not available). Also sort functions with the same execution count alphabetically for a stable order. Base on a suggestion by [email protected].
1 parent 331a290 commit 2dfafc9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

bin/genhtml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use Digest::MD5 qw(md5_base64);
7373

7474
# Global constants
7575
our $title = "LCOV - code coverage report";
76-
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.71 $)';
76+
our $lcov_version = 'LCOV version 1.11 pre (CVS $Revision: 1.72 $)';
7777
our $lcov_url = "http://ltp.sourceforge.net/coverage/lcov.php";
7878
our $tool_name = basename($0);
7979

@@ -4433,7 +4433,11 @@ sub write_header(*$$$$$$$$$$)
44334433
if ($func_coverage) {
44344434
$view .= "<span style=\"font-size: 80%;\">";
44354435
if ($type == $HDR_SOURCE) {
4436-
$view .= " (source / <a href=\"$base_name.func.$html_ext\">functions</a>)";
4436+
if ($sort) {
4437+
$view .= " (source / <a href=\"$base_name.func-sort-c.$html_ext\">functions</a>)";
4438+
} else {
4439+
$view .= " (source / <a href=\"$base_name.func.$html_ext\">functions</a>)";
4440+
}
44374441
} elsif ($type == $HDR_FUNC) {
44384442
$view .= " (<a href=\"$base_name.gcov.$html_ext\">source</a> / functions)";
44394443
}
@@ -5296,8 +5300,10 @@ sub funcview_get_sorted($$$)
52965300
if ($type == 0) {
52975301
return sort(keys(%{$funcdata}));
52985302
}
5299-
return sort({$sumfncdata->{$b} <=> $sumfncdata->{$a}}
5300-
keys(%{$sumfncdata}));
5303+
return sort({
5304+
$sumfncdata->{$b} == $sumfncdata->{$a} ?
5305+
$a cmp $b : $sumfncdata->{$a} <=> $sumfncdata->{$b}
5306+
} keys(%{$sumfncdata}));
53015307
}
53025308

53035309
#

0 commit comments

Comments
 (0)