Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
t/perf: factor out percent calculations
author
Jeff King
<peff@peff.net>
Fri, 17 Aug 2018 20:55:24 +0000
(16:55 -0400)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 20 Aug 2018 21:04:47 +0000
(14:04 -0700)
This will let us reuse the code when we add new values to
aggregate besides times.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/perf/aggregate.perl
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
968e77a
)
diff --git
a/t/perf/aggregate.perl
b/t/perf/aggregate.perl
index bc865160e7e3370f9462beda9d8b3866e3c2111b..3181b087ab5d2624ae64c951600eefe93d21d78c 100755
(executable)
--- a/
t/perf/aggregate.perl
+++ b/
t/perf/aggregate.perl
@@
-19,21
+19,24
@@
sub get_times {
return ($rt, $4, $5);
}
return ($rt, $4, $5);
}
+sub relative_change {
+ my ($r, $firstr) = @_;
+ if ($firstr > 0) {
+ return sprintf "%+.1f%%", 100.0*($r-$firstr)/$firstr;
+ } elsif ($r == 0) {
+ return "=";
+ } else {
+ return "+inf";
+ }
+}
+
sub format_times {
my ($r, $u, $s, $firstr) = @_;
if (!defined $r) {
return "<missing>";
}
my $out = sprintf "%.2f(%.2f+%.2f)", $r, $u, $s;
sub format_times {
my ($r, $u, $s, $firstr) = @_;
if (!defined $r) {
return "<missing>";
}
my $out = sprintf "%.2f(%.2f+%.2f)", $r, $u, $s;
- if (defined $firstr) {
- if ($firstr > 0) {
- $out .= sprintf " %+.1f%%", 100.0*($r-$firstr)/$firstr;
- } elsif ($r == 0) {
- $out .= " =";
- } else {
- $out .= " +inf";
- }
- }
+ $out .= ' ' . relative_change($r, $firstr) if defined $firstr;
return $out;
}
return $out;
}