mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 00:07:30 +00:00
Optimise plugin timings report entries
this format is already supported by the timings host, so no changes are required to support this.
This commit is contained in:
parent
acc8ae87fb
commit
cebdb95265
@ -651,7 +651,7 @@ class PluginManager{
|
||||
throw new PluginException("Plugin attempted to register event handler " . $handlerName . "() to event " . $event . " while not enabled");
|
||||
}
|
||||
|
||||
$timings = new TimingsHandler("Plugin: " . $plugin->getDescription()->getFullName() . " Event: " . $handlerName . "(" . (new \ReflectionClass($event))->getShortName() . ")");
|
||||
$timings = new TimingsHandler($handlerName . "(" . (new \ReflectionClass($event))->getShortName() . ")", group: $plugin->getDescription()->getFullName());
|
||||
|
||||
$registeredListener = new RegisteredListener($handler, $priority, $plugin, $handleCancelled, $timings);
|
||||
HandlerListManager::global()->getListFor($event)->register($registeredListener);
|
||||
|
@ -34,7 +34,7 @@ class TimingsHandler{
|
||||
|
||||
/** @return string[] */
|
||||
public static function printTimings() : array{
|
||||
$result = ["Minecraft"];
|
||||
$groups = [];
|
||||
|
||||
foreach(TimingsRecord::getAll() as $timings){
|
||||
$time = $timings->getTotalTime();
|
||||
@ -46,7 +46,16 @@ class TimingsHandler{
|
||||
|
||||
$avg = $time / $count;
|
||||
|
||||
$result[] = " " . $timings->getName() . " Time: $time Count: " . $count . " Avg: $avg Violations: " . $timings->getViolations();
|
||||
$group = $timings->getGroup();
|
||||
$groups[$group][] = $timings->getName() . " Time: $time Count: " . $count . " Avg: $avg Violations: " . $timings->getViolations();
|
||||
}
|
||||
$result = [];
|
||||
|
||||
foreach($groups as $groupName => $lines){
|
||||
$result[] = $groupName;
|
||||
foreach($lines as $line){
|
||||
$result[] = " $line";
|
||||
}
|
||||
}
|
||||
|
||||
$result[] = "# Version " . Server::getInstance()->getVersion();
|
||||
@ -102,11 +111,14 @@ class TimingsHandler{
|
||||
|
||||
public function __construct(
|
||||
private string $name,
|
||||
private ?TimingsHandler $parent = null
|
||||
private ?TimingsHandler $parent = null,
|
||||
private string $group = "Minecraft"
|
||||
){}
|
||||
|
||||
public function getName() : string{ return $this->name; }
|
||||
|
||||
public function getGroup() : string{ return $this->group; }
|
||||
|
||||
public function startTiming() : void{
|
||||
if(self::$enabled){
|
||||
$this->internalStartTiming(hrtime(true));
|
||||
|
@ -88,6 +88,8 @@ final class TimingsRecord{
|
||||
|
||||
public function getName() : string{ return $this->handler->getName(); }
|
||||
|
||||
public function getGroup() : string{ return $this->handler->getGroup(); }
|
||||
|
||||
public function getCount() : int{ return $this->count; }
|
||||
|
||||
public function getCurCount() : int{ return $this->curCount; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user