[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[OSSTEST PATCH 14/60] history reporting (nfc): Use cacheable_fn for power methods


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Date: Fri, 14 Aug 2020 18:21:19 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
  • Delivery-date: Fri, 14 Aug 2020 17:26:34 +0000
  • Ironport-sdr: 0LIije89+jZss5FbdKtuoJ2XR1nDpq+FwGeNy498e/CIP+E26WemoojBHOh/B1nQtePSLfNg4O QBSzVdjVmBJjO4oh9lYATF/DaOZyK3JUgshcGp4EAGPl+x+92A6LtYQ2Jlk4bKkN9OV78JyVqm hbqU6r6fk6E+f8f86tekDb1FySH9b3vFmkp+05EpJMPor0RGhfl0dOHyvtL4Oxvkwz3XIgtgc+ A/BPLDAg7/H2RBYnMhficbywNy+PNo91GdoRI7UNiTII1tfIppWQGuT/lBZYMBDGqsQxNzVHqQ ASE=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Avoids open-coding knowledge of the $jr convention at this use site.
%powers becomes %$powers, so it's a bit noisy.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 sg-report-host-history | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/sg-report-host-history b/sg-report-host-history
index 43ddd2af..9510757f 100755
--- a/sg-report-host-history
+++ b/sg-report-host-history
@@ -387,12 +387,8 @@ END
        my $ri = report_run_getinfo({ %$jr, %$ir });
        print H "<td $ri->{ColourAttr}>$ri->{Content}</td>\n";
 
-       my %powers;
-       if ($jr->{'%p'}) {
-           %powers = %{ $jr->{'%p'} };
-           $runvarq_hits++;
-       } else {
-           $runvarq_misses++;
+       my $powers = cacheable_fn($jr, 'b', sub {
+            my %powers;
            $jrunvarq->execute($jr->{flight}, $jr->{job},
                               db_quote_like_pattern($ident));
            my %runvars;
@@ -404,8 +400,8 @@ END
                next unless $r =~ m{^\Q${ident}\E_power_};
                $powers{$'} = $runvars{$r};
            }
-           $jr->{'%p'} = { %powers };
-       }
+           \%powers;
+       });
        my $skipped = 0;
         my $any_power = 0;
         my $pr_power_colour = sub {
@@ -421,7 +417,7 @@ END
            for (; $skipped; $skipped--) {
                $pr_power_colour->($grey_mid, " - ");
            }
-           my $how = $powers{$wh};
+           my $how = $powers->{$wh};
            my $colour =
                $how =~ /PDU/      ? $yellow :
                $how =~ /Combined/ ? $yellow :
@@ -430,11 +426,11 @@ END
             $pr_power_colour->($colour, " $how ");
        };
        foreach my $wh (qw(install recover)) {
-           $skipped++, next unless exists $powers{$wh};
+           $skipped++, next unless exists $powers->{$wh};
            $pr_power->($wh);
-           delete $powers{$wh};
+           delete $powers->{$wh};
        }
-       foreach my $wh (sort keys %powers) {
+       foreach my $wh (sort keys %$powers) {
            $pr_power->($wh);
        }
         print H "<td>" if !$any_power;
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.