[tools] testbot: Filter the jobs in GetStatistics().
This reduces the number of Tasks that need to be loaded from the database and processed in order to collect the statistics for short periods of time. Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com> --- I guess this was not done initially because FilterNull() and FilterOr() were added after the stats code. A big source of inefficiency is the loading of the Tasks a handful at a time. But fixing that requires a bigger code reorganisation. There are some smaller optimisations that can provide 10-20% speedups like caching some object properties to avoid the AUTOLOAD performance penalty. But whether they make sense depends on how the performance of that mechanism evolves. --- testbot/lib/WineTestBot/Activity.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm index f7579057e..d395a12a8 100644 --- a/testbot/lib/WineTestBot/Activity.pm +++ b/testbot/lib/WineTestBot/Activity.pm @@ -31,6 +31,8 @@ our @EXPORT = qw(GetActivity GetStatistics); use List::Util qw(max); use Scalar::Util qw(weaken); +use ObjectModel::Collection; + use WineTestBot::Config; use WineTestBot::Jobs; use WineTestBot::RecordGroups; @@ -342,9 +344,12 @@ sub GetStatistics($;$) my ($GlobalStats, $HostsStats, $VMsStats) = ({}, {}, {}); - my @JobTimes; my $Jobs = CreateJobs(); my $Cutoff = $Seconds ? (time() - $Seconds) : 0; + $Jobs->AddFilter(FilterOr(FilterNull("Ended"), + FilterValue("Ended", ">=", [$Cutoff]))); + + my @JobTimes; foreach my $Job (@{$Jobs->GetItems()}) { my $CountsAsNew = ($Job->Submitted >= $Cutoff); @@ -372,6 +377,7 @@ sub GetStatistics($;$) $GlobalStats->{"newtasks.count"}++; $HostStats->{"newtasks.count"}++ if ($HostStats); } + # The Task may have ended much earlier than the Job next if (!$Task->Ended or $Task->Ended < $Cutoff); $GlobalStats->{"donetasks.count"}++; $HostStats->{"donetasks.count"}++ if ($HostStats); -- 2.30.2
participants (1)
-
Francois Gouget