Francois Gouget : testbot: Simplify computing the min and max activity values.
Alexandre Julliard
julliard at winehq.org
Tue Feb 6 15:09:38 CST 2018
Module: tools
Branch: master
Commit: ab64e577473ba0546d10341fee81cd20c77b4329
URL: https://source.winehq.org/git/tools.git/?a=commit;h=ab64e577473ba0546d10341fee81cd20c77b4329
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Feb 6 02:57:08 2018 +0100
testbot: Simplify computing the min and max activity values.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/lib/WineTestBot/Activity.pm | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm
index 2c21d9f..a2bd1b0 100644
--- a/testbot/lib/WineTestBot/Activity.pm
+++ b/testbot/lib/WineTestBot/Activity.pm
@@ -38,6 +38,17 @@ require Exporter;
@EXPORT = qw(&GetActivity &GetStatistics);
+sub _UpdateMin($$)
+{
+ $_[0] = $_[1] if (!defined $_[0] or $_[1] < $_[0]);
+}
+
+sub _UpdateMax($$)
+{
+ $_[0] = $_[1] if (!defined $_[0] or $_[0] < $_[1]);
+}
+
+
=pod
=over 12
@@ -110,7 +121,7 @@ sub GetActivity($;$)
start => $RecordGroup->Timestamp };
$ActivityHash->{$RecordGroup->Id} = $Group;
push @$Activity, $Group;
- $MinId = $RecordGroup->Id if (!defined $MinId or $RecordGroup->Id < $MinId);
+ _UpdateMin($MinId, $RecordGroup->Id);
}
if (!defined $MinId)
{
@@ -375,14 +386,8 @@ sub GetStatistics($)
_AddFullStat($GlobalStats, "jobs.time", $Time, undef, $Job);
push @JobTimes, $Time;
- if (!exists $GlobalStats->{start} or $GlobalStats->{start} > $Job->Submitted)
- {
- $GlobalStats->{start} = $Job->Submitted;
- }
- if (!exists $GlobalStats->{end} or $GlobalStats->{end} < $Job->Ended)
- {
- $GlobalStats->{end} = $Job->Ended;
- }
+ _UpdateMin($GlobalStats->{start}, $Job->Submitted);
+ _UpdateMax($GlobalStats->{end}, $Job->Ended);
}
}
@@ -401,14 +406,8 @@ sub GetStatistics($)
$GlobalStats->{"records.count"} = $Counters->{records};
foreach my $Group (@$Activity)
{
- if (!$VMsStats->{start} or $VMsStats->{start} > $Group->{start})
- {
- $VMsStats->{start} = $Group->{start};
- }
- if (!$VMsStats->{end} or $VMsStats->{end} < $Group->{end})
- {
- $VMsStats->{end} = $Group->{end};
- }
+ _UpdateMin($VMsStats->{start}, $Group->{start});
+ _UpdateMax($VMsStats->{end}, $Group->{end});
next if (!$Group->{statusvms});
my ($IsGroupBusy, %IsHostBusy);
More information about the wine-cvs
mailing list