mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-30 07:09:56 +00:00
Timings: added timers for player data I/O
This commit is contained in:
parent
37ace19857
commit
4d42f0c3db
@ -519,6 +519,7 @@ class Server{
|
||||
}
|
||||
|
||||
public function getOfflinePlayerData(string $name) : ?CompoundTag{
|
||||
return Timings::$syncPlayerDataLoad->time(function() use ($name) : ?CompoundTag{
|
||||
$name = strtolower($name);
|
||||
$path = $this->getPlayerDataPath($name);
|
||||
|
||||
@ -543,6 +544,7 @@ class Server{
|
||||
}
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public function saveOfflinePlayerData(string $name, CompoundTag $nbtTag) : void{
|
||||
@ -554,6 +556,7 @@ class Server{
|
||||
$ev->call();
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
Timings::$syncPlayerDataSave->time(function() use ($name, $ev) : void{
|
||||
$nbt = new BigEndianNbtSerializer();
|
||||
try{
|
||||
file_put_contents($this->getPlayerDataPath($name), zlib_encode($nbt->write(new TreeRoot($ev->getSaveData())), ZLIB_ENCODING_GZIP));
|
||||
@ -561,6 +564,7 @@ class Server{
|
||||
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,11 @@ abstract class Timings{
|
||||
/** @var TimingsHandler */
|
||||
public static $craftingDataCacheRebuildTimer;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $syncPlayerDataLoad;
|
||||
/** @var TimingsHandler */
|
||||
public static $syncPlayerDataSave;
|
||||
|
||||
/** @var TimingsHandler[] */
|
||||
public static $entityTypeTimingMap = [];
|
||||
/** @var TimingsHandler[] */
|
||||
@ -155,6 +160,9 @@ abstract class Timings{
|
||||
self::$permissibleCalculationTimer = new TimingsHandler("Permissible Calculation");
|
||||
self::$permissionDefaultTimer = new TimingsHandler("Default Permission Calculation");
|
||||
|
||||
self::$syncPlayerDataLoad = new TimingsHandler("Player Data Load");
|
||||
self::$syncPlayerDataSave = new TimingsHandler("Player Data Save");
|
||||
|
||||
self::$entityMoveTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "entityMove");
|
||||
self::$playerCheckNearEntitiesTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "checkNearEntities");
|
||||
self::$tickEntityTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity");
|
||||
|
Loading…
x
Reference in New Issue
Block a user