Module: tools
Branch: master
Commit: 2ee6ee59d76c3935b1279977a4ff786b2deb7556
URL: https://source.winehq.org/git/tools.git/?a=commit;h=2ee6ee59d76c3935b127997…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Jan 17 01:23:05 2018 +0100
testbot: Fix the CompareRecordGroups() documentation and variable names.
The RecordGroup Id is an AUTO_INCREMENT field. These never wrap!
Also, while that field is defined as an INT(6), it is a 32 bit integer
anyway so we will not run out of ids for a long time. Generally
speaking, for integers the display width (6 here) is meaningless as far
as the TestBot is concerned.
Also use more descriptive variable names. $a and $b were a bit
misleading too since they have special meaning in the context of the
sort() function, meaning which they don't have here.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/WineTestBot/RecordGroups.pm | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/testbot/lib/WineTestBot/RecordGroups.pm b/testbot/lib/WineTestBot/RecordGroups.pm
index fc1c252..707d0ac 100644
--- a/testbot/lib/WineTestBot/RecordGroups.pm
+++ b/testbot/lib/WineTestBot/RecordGroups.pm
@@ -95,12 +95,12 @@ sub CreateRecordGroups(;$)
sub CompareRecordGroups($$)
{
- my ($a, $b) = @_;
+ my ($RecordGroup1, $RecordGroup2) = @_;
- # The Id will wrap eventually so sort by Timestamp
- # and only use the Id to break ties.
- return $a->Timestamp <=> $b->Timestamp ||
- $a->Id <=> $b->Id;
+ # The Timestamps have a 1 second granularity and may have duplicates.
+ # So use the Id to break ties.
+ return $RecordGroup1->Timestamp <=> $RecordGroup2->Timestamp ||
+ $RecordGroup1->Id <=> $RecordGroup2->Id;
}
=pod
Module: tools
Branch: master
Commit: dfff27816fb06dadd5b07b94d64c5e7ef3096155
URL: https://source.winehq.org/git/tools.git/?a=commit;h=dfff27816fb06dadd5b07b9…
Author: Francois Gouget <fgouget(a)codeweavers.com>
Date: Wed Jan 17 01:22:58 2018 +0100
testbot: Return the activity records as a sorted list.
The callers need a sorted list rather than a random access structure.
So this avoids forcing them to deal with sorting the activity records
again and mildly speeds things up.
Signed-off-by: Francois Gouget <fgouget(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
---
testbot/lib/WineTestBot/Activity.pm | 33 ++++++++++++++++++---------------
testbot/web/Activity.pl | 4 ++--
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/testbot/lib/WineTestBot/Activity.pm b/testbot/lib/WineTestBot/Activity.pm
index 5a5d232..58169ae 100644
--- a/testbot/lib/WineTestBot/Activity.pm
+++ b/testbot/lib/WineTestBot/Activity.pm
@@ -44,9 +44,13 @@ require Exporter;
=item C<GetActivity()>
Loads the records for the specified VMs and processes them to build a structure
-describing the TestBot activity. The structure is as follows:
+describing the TestBot activity.
- { <GroupNo1> => {
+Returns a list of the activity records, sorted from the oldest to the newest.
+Each entry contains a structure grouping all the state and event information
+for the specified timestamp. Entries have the following structure:
+
+ {
start => <StartTimestamp>,
end => <EndTimestamp>,
runnable => <RunnableTasksCount>,
@@ -78,12 +82,10 @@ describing the TestBot activity. The structure is as follows:
...
},
},
- },
- <GroupNo2> => {
- ...
- },
- ...
- }
+ }
+
+GetActivity() also returns a table with the number of records and record groups
+that were processed.
=back
=cut
@@ -91,14 +93,16 @@ describing the TestBot activity. The structure is as follows:
sub GetActivity($)
{
my ($VMs) = @_;
- my ($Activity, $Counters) = ({}, {});
+ my ($ActivityHash, $Activity, $Counters) = ({}, [], {});
### First load all the RecordGroups
my $RecordGroups = CreateRecordGroups();
$Counters->{recordgroups} = $RecordGroups->GetItemsCount();
- foreach my $RecordGroup (@{$RecordGroups->GetItems()})
+ foreach my $RecordGroup (sort CompareRecordGroups @{$RecordGroups->GetItems()})
{
- $Activity->{$RecordGroup->Id} = { start => $RecordGroup->Timestamp };
+ my $Group = { start => $RecordGroup->Timestamp };
+ $ActivityHash->{$RecordGroup->Id} = $Group;
+ push @$Activity, $Group;
}
### And then load all the Records in one go
@@ -110,7 +114,7 @@ sub GetActivity($)
$Counters->{records} = $Records->GetItemsCount();
foreach my $Record (@{$Records->GetItems()})
{
- my $Group = $Activity->{$Record->RecordGroupId};
+ my $Group = $ActivityHash->{$Record->RecordGroupId};
if ($Record->Type eq "tasks" and $Record->Name eq "counters")
{
($Group->{runnable}, $Group->{queued}) = split / /, $Record->Value;
@@ -196,9 +200,8 @@ sub GetActivity($)
### Fill the holes in the table, compute end times, etc.
my ($LastGroup, %LastStatusVMs);
- foreach my $RecordGroup (sort CompareRecordGroups @{$RecordGroups->GetItems()})
+ foreach my $Group (@$Activity)
{
- my $Group = $Activity->{$RecordGroup->Id};
my $StatusVMs = $Group->{statusvms};
my $ResultVMs = $Group->{resultvms};
next if (!$StatusVMs and !$ResultVMs);
@@ -380,7 +383,7 @@ sub GetStatistics($)
my ($Activity, $Counters) = GetActivity($VMs);
$GlobalStats->{"recordgroups.count"} = $Counters->{recordgroups};
$GlobalStats->{"records.count"} = $Counters->{records};
- foreach my $Group (values %$Activity)
+ foreach my $Group (@$Activity)
{
if (!$VMsStats->{start} or $VMsStats->{start} > $Group->{start})
{
diff --git a/testbot/web/Activity.pl b/testbot/web/Activity.pl
index 5a730df..f8b7b5a 100644
--- a/testbot/web/Activity.pl
+++ b/testbot/web/Activity.pl
@@ -133,9 +133,9 @@ EOF
print "<tbody>\n";
my ($Activity, $_Counters) = GetActivity($VMs);
- foreach my $GroupNo (sort { $b <=> $a } keys %$Activity)
+ for (my $Index = @$Activity; $Index--; )
{
- my $Group = $Activity->{$GroupNo};
+ my $Group = $Activity->[$Index];
next if (!$Group->{statusvms});
print "<tr><td>", _GetHtmlTime($Group->{start}), "</td>";