TimingsHandler
Methods
__construct()
public function __construct(string $name, ?\pocketmine\timings\TimingsHandler $parent = null, string $group = \pocketmine\timings\Timings::GROUP_MINECRAFT)createReportFile()
public static function createReportFile(string $directory, ?string $fileName = null) : \pocketmine\promise\PromiseCreates a timings report file locally in the provided file path. Collects timings data and returns a promise that resolves with the created file.
getCollectCallbacks()
public static function getCollectCallbacks() : \pocketmine\utils\ObjectSetgetGroup()
public function getGroup() : stringgetName()
public function getName() : stringgetReloadCallbacks()
public static function getReloadCallbacks() : \pocketmine\utils\ObjectSetgetStartTime()
public static function getStartTime() : floatgetToggleCallbacks()
public static function getToggleCallbacks() : \pocketmine\utils\ObjectSetisEnabled()
public static function isEnabled() : boolnow() 5.46.0
public static function now() : intMonotonic clock in nanoseconds (arbitrary origin), like hrtime(true). hrtime() costs several microseconds on virtual machines without a paravirtualised clock, more than most timed sections; when the chunkutils2 extension provides the CPU time stamp counter it is used instead (a few nanoseconds per read), calibrated against hrtime() once per thread.
printCurrentThreadRecords()
public static function printCurrentThreadRecords() : arrayprintTimings()
public static function printTimings() : arrayDeprecated
This only collects timings from the main thread. Collecting timings from all threads is an async
reload()
public static function reload() : voidrequestPrintTimings()
public static function requestPrintTimings() : \pocketmine\promise\PromiseCollects timings asynchronously, allowing timings from multiple threads to be aggregated into a single report.
NOTE: You need to add a callback to collectCallbacks if you want to include timings from other threads. They won't be automatically collected if you don't, since the main thread has no way to access them.
This is an asynchronous operation, and the result is returned as a promise. The caller must add a callback to the returned promise to get the complete timings report.
setEnabled()
public static function setEnabled(bool $enable = true) : voidstartTiming()
public function startTiming() : voidstopTiming()
public function stopTiming() : voidtick()
public static function tick(bool $measure = true) : voidtime()
public function time(\Closure $closure)