Timings: added broadcastPackets timer

the body of this function is potentially very expensive and isn't currently recorded by any timer.
This commit is contained in:
Dylan K. Taylor 2020-11-12 17:53:07 +00:00
parent afbef242c6
commit 31089ce3b2
2 changed files with 46 additions and 39 deletions

View File

@ -1182,6 +1182,7 @@ class Server{
throw new \InvalidArgumentException("Cannot broadcast empty list of packets");
}
return Timings::$broadcastPackets->time(function() use ($players, $packets) : bool{
/** @var NetworkSession[] $recipients */
$recipients = [];
foreach($players as $player){
@ -1230,6 +1231,7 @@ class Server{
}
return true;
});
}
/**

View File

@ -118,6 +118,9 @@ abstract class Timings{
/** @var TimingsHandler[] */
public static $pluginTaskTimingMap = [];
/** @var TimingsHandler */
public static $broadcastPackets;
public static function init() : void{
if(self::$initialized){
return;
@ -138,6 +141,8 @@ abstract class Timings{
self::$playerNetworkReceiveDecompressTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Receive - Decompression", self::$playerNetworkReceiveTimer);
self::$playerNetworkReceiveDecryptTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Receive - Decryption", self::$playerNetworkReceiveTimer);
self::$broadcastPackets = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Broadcast Packets", self::$playerNetworkSendTimer);
self::$playerChunkOrderTimer = new TimingsHandler("Player Order Chunks");
self::$playerChunkSendTimer = new TimingsHandler("Player Send Chunks");
self::$connectionTimer = new TimingsHandler("Connection Handler");