mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 10:19:39 +00:00
Added settings.profile-report-trigger to only extract timings on a given tps rate
This commit is contained in:
parent
7705d8c52f
commit
63a5269313
@ -139,6 +139,8 @@ class Server{
|
||||
/** @var PluginManager */
|
||||
private $pluginManager = null;
|
||||
|
||||
private $profilingTickRate = 20;
|
||||
|
||||
/** @var AutoUpdater */
|
||||
private $updater = null;
|
||||
|
||||
@ -1672,6 +1674,7 @@ class Server{
|
||||
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
||||
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
||||
$this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
|
||||
$this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20);
|
||||
$this->pluginManager->registerInterface(PharPluginLoader::class);
|
||||
|
||||
set_exception_handler([$this, "exceptionHandler"]);
|
||||
@ -2456,12 +2459,12 @@ class Server{
|
||||
|
||||
Timings::$serverTickTimer->stopTiming();
|
||||
|
||||
TimingsHandler::tick();
|
||||
|
||||
$now = microtime(true);
|
||||
$tick = min(20, 1 / max(0.001, $now - $tickTime));
|
||||
$use = min(1, ($now - $tickTime) / 0.05);
|
||||
|
||||
TimingsHandler::tick($tick <= $this->profilingTickRate);
|
||||
|
||||
if($this->maxTick > $tick){
|
||||
$this->maxTick = $tick;
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ class TimingsHandler{
|
||||
private $parent = null;
|
||||
|
||||
private $count = 0;
|
||||
private $curCount = 0;
|
||||
private $start = 0;
|
||||
private $timingDepth = 0;
|
||||
private $totalTime = 0;
|
||||
@ -97,14 +98,26 @@ class TimingsHandler{
|
||||
}
|
||||
}
|
||||
|
||||
public static function tick(){
|
||||
public static function tick($measure = true){
|
||||
if(PluginManager::$useTimings){
|
||||
foreach(self::$HANDLERS as $timings){
|
||||
if($timings->curTickTotal > 0.05){
|
||||
$timings->violations += round($timings->curTickTotal / 0.05);
|
||||
if($measure){
|
||||
foreach(self::$HANDLERS as $timings){
|
||||
if($timings->curTickTotal > 0.05){
|
||||
$timings->violations += round($timings->curTickTotal / 0.05);
|
||||
}
|
||||
$timings->curTickTotal = 0;
|
||||
$timings->curCount = 0;
|
||||
$timings->timingDepth = 0;
|
||||
}
|
||||
}else{
|
||||
foreach(self::$HANDLERS as $timings){
|
||||
$timings->totalTime -= $timings->curTickTotal;
|
||||
$timings->count -= $timings->curCount;
|
||||
|
||||
$timings->curTickTotal = 0;
|
||||
$timings->curCount = 0;
|
||||
$timings->timingDepth = 0;
|
||||
}
|
||||
$timings->curTickTotal = 0;
|
||||
$timings->timingDepth = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,7 +140,8 @@ class TimingsHandler{
|
||||
$diff = microtime(true) - $this->start;
|
||||
$this->totalTime += $diff;
|
||||
$this->curTickTotal += $diff;
|
||||
$this->count++;
|
||||
++$this->curCount;
|
||||
++$this->count;
|
||||
$this->start = 0;
|
||||
if($this->parent instanceof TimingsHandler){
|
||||
$this->parent->stopTiming();
|
||||
@ -137,6 +151,7 @@ class TimingsHandler{
|
||||
|
||||
public function reset(){
|
||||
$this->count = 0;
|
||||
$this->curCount = 0;
|
||||
$this->violations = 0;
|
||||
$this->curTickTotal = 0;
|
||||
$this->totalTime = 0;
|
||||
|
@ -16,6 +16,8 @@ settings:
|
||||
deprecated-verbose: true
|
||||
#Enable plugin and core profiling by default
|
||||
enable-profiling: false
|
||||
#Will only add results when tick measurement is below or equal to given value (default 20)
|
||||
profile-report-trigger: 20
|
||||
#Sends anonymous statistics to create usage reports
|
||||
send-usage: true
|
||||
#Number of AsyncTask workers.
|
||||
|
Loading…
x
Reference in New Issue
Block a user