PocketMine-MP 5.15.1 git-5ef247620a7c6301a849b54e5ef1009217729fc8
WorldTimings.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\world;
25
27
29
30 public TimingsHandler $setBlock;
31 public TimingsHandler $doBlockLightUpdates;
32 public TimingsHandler $doBlockSkyLightUpdates;
33
34 public TimingsHandler $doChunkUnload;
35 public TimingsHandler $scheduledBlockUpdates;
36 public TimingsHandler $neighbourBlockUpdates;
37 public TimingsHandler $randomChunkUpdates;
38 public TimingsHandler $randomChunkUpdatesChunkSelection;
39 public TimingsHandler $doChunkGC;
40 public TimingsHandler $entityTick;
41 public TimingsHandler $tileTick;
42 public TimingsHandler $doTick;
43
44 public TimingsHandler $syncChunkSend;
45 public TimingsHandler $syncChunkSendPrepare;
46
47 public TimingsHandler $syncChunkLoad;
48 public TimingsHandler $syncChunkLoadData;
49 public TimingsHandler $syncChunkLoadFixInvalidBlocks;
50 public TimingsHandler $syncChunkLoadEntities;
51 public TimingsHandler $syncChunkLoadTileEntities;
52
53 public TimingsHandler $syncDataSave;
54 public TimingsHandler $syncChunkSave;
55
56 public TimingsHandler $chunkPopulationOrder;
57 public TimingsHandler $chunkPopulationCompletion;
58
63 private static array $aggregators = [];
64
65 private static function newTimer(string $worldName, string $timerName) : TimingsHandler{
66 $aggregator = self::$aggregators[$timerName] ??= new TimingsHandler("Worlds - $timerName"); //displayed in Minecraft primary table
67
68 return new TimingsHandler("$worldName - $timerName", $aggregator);
69 }
70
71 public function __construct(World $world){
72 $name = $world->getFolderName();
73
74 $this->setBlock = self::newTimer($name, "Set Blocks");
75 $this->doBlockLightUpdates = self::newTimer($name, "Block Light Updates");
76 $this->doBlockSkyLightUpdates = self::newTimer($name, "Sky Light Updates");
77
78 $this->doChunkUnload = self::newTimer($name, "Unload Chunks");
79 $this->scheduledBlockUpdates = self::newTimer($name, "Scheduled Block Updates");
80 $this->neighbourBlockUpdates = self::newTimer($name, "Neighbour Block Updates");
81 $this->randomChunkUpdates = self::newTimer($name, "Random Chunk Updates");
82 $this->randomChunkUpdatesChunkSelection = self::newTimer($name, "Random Chunk Updates - Chunk Selection");
83 $this->doChunkGC = self::newTimer($name, "Garbage Collection");
84 $this->entityTick = self::newTimer($name, "Entity Tick");
85 $this->tileTick = self::newTimer($name, "Block Entity Tick");
86 $this->doTick = self::newTimer($name, "World Tick");
87
88 $this->syncChunkSend = self::newTimer($name, "Player Send Chunks");
89 $this->syncChunkSendPrepare = self::newTimer($name, "Player Send Chunk Prepare");
90
91 $this->syncChunkLoad = self::newTimer($name, "Chunk Load");
92 $this->syncChunkLoadData = self::newTimer($name, "Chunk Load - Data");
93 $this->syncChunkLoadFixInvalidBlocks = self::newTimer($name, "Chunk Load - Fix Invalid Blocks");
94 $this->syncChunkLoadEntities = self::newTimer($name, "Chunk Load - Entities");
95 $this->syncChunkLoadTileEntities = self::newTimer($name, "Chunk Load - Block Entities");
96
97 $this->syncDataSave = self::newTimer($name, "Data Save");
98 $this->syncChunkSave = self::newTimer($name, "Chunk Save");
99
100 $this->chunkPopulationOrder = self::newTimer($name, "Chunk Population - Order");
101 $this->chunkPopulationCompletion = self::newTimer($name, "Chunk Population - Completion");
102 }
103}