GroupMembershipResolver: Improve Benchmark output

This commit is contained in:
Markus Frosch 2018-03-09 13:31:52 +01:00 committed by Thomas Gelf
parent 3b812fab7d
commit f6cf1a4245
1 changed files with 25 additions and 0 deletions

View File

@ -387,6 +387,8 @@ abstract class GroupMembershipResolver
$objects = & $this->objects;
}
$times = array();
foreach ($objects as $object) {
if ($object->shouldBeRemoved()) {
continue;
@ -394,6 +396,8 @@ abstract class GroupMembershipResolver
if ($object->isTemplate()) {
continue;
}
$mt = microtime(true);
// TODO: fix this last hard host dependency
$resolver = HostApplyMatches::prepare($object);
foreach ($groups as $groupId => $filter) {
@ -406,12 +410,33 @@ abstract class GroupMembershipResolver
$mappings[$groupId][$id] = $id;
}
}
$times[] = (microtime(true) - $mt) * 1000;
}
$count = count($times);
$min = $max = $avg = 0;
if ($count > 0) {
$min = min($times);
$max = max($times);
$avg = array_sum($times) / $count;
}
Benchmark::measure(sprintf(
'Hostgroup apply recalculated: objects=%d groups=%d min=%d max=%d avg=%d (in ms)',
$count,
count($groups),
$min,
$max,
$avg
));
foreach ($this->fetchMissingSingleAssignments() as $row) {
$mappings[$row->group_id][$row->object_id] = $row->object_id;
}
Benchmark::measure('Done with single assignments');
$this->newMappings = $mappings;
}