mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-09 13:14:54 +00:00
Merge branch 'stable' into minor-next
This commit is contained in:
commit
4ef21fabab
@ -31,6 +31,7 @@ use function hrtime;
|
|||||||
use function max;
|
use function max;
|
||||||
use function min;
|
use function min;
|
||||||
use function number_format;
|
use function number_format;
|
||||||
|
use function sprintf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows threads to manually trigger the cyclic garbage collector using a threshold like PHP's own garbage collector,
|
* Allows threads to manually trigger the cyclic garbage collector using a threshold like PHP's own garbage collector,
|
||||||
@ -48,6 +49,7 @@ final class GarbageCollectorManager{
|
|||||||
|
|
||||||
private int $threshold = self::GC_THRESHOLD_DEFAULT;
|
private int $threshold = self::GC_THRESHOLD_DEFAULT;
|
||||||
private int $collectionTimeTotalNs = 0;
|
private int $collectionTimeTotalNs = 0;
|
||||||
|
private int $runs = 0;
|
||||||
|
|
||||||
private \Logger $logger;
|
private \Logger $logger;
|
||||||
private TimingsHandler $timings;
|
private TimingsHandler $timings;
|
||||||
@ -96,7 +98,16 @@ final class GarbageCollectorManager{
|
|||||||
|
|
||||||
$time = $end - $start;
|
$time = $end - $start;
|
||||||
$this->collectionTimeTotalNs += $time;
|
$this->collectionTimeTotalNs += $time;
|
||||||
$this->logger->debug("gc_collect_cycles: " . number_format($time) . " ns ($rootsBefore -> $rootsAfter roots, $cycles cycles collected) - total GC time: " . number_format($this->collectionTimeTotalNs) . " ns");
|
$this->runs++;
|
||||||
|
$this->logger->info(sprintf(
|
||||||
|
"Run #%d took %s ms (%s -> %s roots, %s cycles collected) - cumulative GC time: %s ms",
|
||||||
|
$this->runs,
|
||||||
|
number_format($time / 1_000_000, 2),
|
||||||
|
$rootsBefore,
|
||||||
|
$rootsAfter,
|
||||||
|
$cycles,
|
||||||
|
number_format($this->collectionTimeTotalNs / 1_000_000, 2)
|
||||||
|
));
|
||||||
|
|
||||||
return $cycles;
|
return $cycles;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user