public static function loadData() { global $ini; $timings = Timings::getInstance(); $timings->loadData(); $data = TimingsMaster::getInstance(); $tpl = self::getInstance(); $ranges = []; $first = -1; foreach ($data->data as $history) { $ranges[] = $history->start; $ranges[] = $history->end; if ($first === -1 || $first > $history->start) { $first = $history->start; } } $ranges = array_values(array_unique($ranges)); //$ranges = array_unique($ranges); //sort($ranges); $last = count($ranges) - 1; $tpl->js['ranges'] = $ranges; $defStart = (int) ($timings->id === $ini['dev_id'] && !empty($ini['dev_def_start']) ? $ini['dev_def_start'] : $ranges[0]); $defEnd = (int) ($timings->id === $ini['dev_id'] && !empty($ini['dev_def_end']) ? $ini['dev_def_end'] : $ranges[$last]); $tpl->js['start'] = $start = (int) (!empty($_GET['start']) ? $_GET['start'] : $defStart); $tpl->js['end'] = $end = (int) (!empty($_GET['end']) ? $_GET['end'] : $defEnd); /** * @var TimingHandler[] $handlerData */ $handlerData = []; $lagData = []; $tpsData = []; $tentData = []; $entData = []; $aentData = []; $chunkData = []; $playerData = []; $timestamps = []; $masterHandler = null; $max = 0; $areaMap = []; foreach ($data->data as $history) { $tileEntities = 0; $entities = 0; $chunks = 0; $players = 0; foreach ($history->worldData as $world) { foreach ($world->chunks as $chunk) { $areaId = $chunk->areaId; if (!array_key_exists($areaId, $areaMap)) { $areaMap[$areaId] = ["count" => 0, "x" => $chunk->areaLocX, "z" => $chunk->areaLocZ, "e" => [], "ec" => 0, "te" => [], "tec" => 0]; } $areaMap[$areaId]['count']++; foreach ($chunk->tileEntities as $id => $count) { $areaMap[$areaId]['te'][$id] += $count; $areaMap[$areaId]['tec'] += $count; } foreach ($chunk->entities as $id => $count) { $areaMap[$areaId]['e'][$id] += $count; $areaMap[$areaId]['ec'] += $count; } $chunks++; } } $firstMP = $history->minuteReports[0]; for ($i = $firstMP->time; $i - $first < 65; $i += 60) { $clone = clone $firstMP; $clone->time = $first; array_unshift($history->minuteReports, $clone); } foreach ($history->minuteReports as $mp) { $total = $mp->fullServerTick->total; $lag = $mp->fullServerTick->lagTotal; $max = max($total, $max); $timestamps[] = $mp->time; $tpsData[] = $mp->tps > 19.85 ? 20 : $mp->tps; $lagData[] = $lag; $chunkData[] = $chunks; $entData[] = $mp->ticks->entityTicks / $mp->ticks->timedTicks; $playerData[] = $mp->ticks->playerTicks / $mp->ticks->timedTicks; $aentData[] = $mp->ticks->activatedEntityTicks / $mp->ticks->timedTicks; $tentData[] = $mp->ticks->tileEntityTicks / $mp->ticks->timedTicks; } if ($history->start >= $start && $history->end <= $end) { foreach ($history->handlers as $handler) { $id = $handler->id->id; if (!array_key_exists($id, $handlerData)) { $handlerData[$id] = clone $handler; $handlerData[$id]->mergedCount = 1; } else { $handlerData[$id]->addDataFromHandler($handler); } if ($handler->id->name === "Full Server Tick" && $masterHandler === null) { $masterHandler = $handlerData[$id]; } } } } if (DEBUGGING && util::array_get($_GET['showmaster'])) { util::var_dump($masterHandler); } $tpl->handlerData = $handlerData; $tpl->js['stamps'] = $timestamps; $tpl->js['maxTime'] = $max; $tpl->js['chunkData'] = $chunkData; $tpl->js['entData'] = $entData; $tpl->js['aentData'] = $aentData; $tpl->js['tentData'] = $tentData; $tpl->js['plaData'] = $playerData; $tpl->js['lagData'] = $lagData; $tpl->js['tpsData'] = $tpsData; $tpl->js['id'] = $timings->id; $tpl->lagData = $lagData; $tpl->tpsData = $tpsData; $tpl->masterHandler = $masterHandler; }
public static function loadData() { $timings = Timings::getInstance(); $timings->loadData(); $data = TimingsMaster::getInstance(); $tpl = self::getInstance(); $ranges = []; foreach ($data->data as $history) { $ranges[] = $history->start; $ranges[] = $history->end; } //$ranges = array_unique($ranges); //sort($ranges); $last = count($ranges) - 1; $tpl->js['ranges'] = $ranges; $tpl->js['start'] = $start = !empty($_GET['start']) ? intval($_GET['start']) : $ranges[$last - 1]; $tpl->js['end'] = $end = !empty($_GET['end']) ? intval($_GET['end']) : $ranges[$last]; /** * @var TimingHandler[] $handlerData */ $handlerData = []; $lagData = []; $tpsData = []; $tentData = []; $entData = []; $aentData = []; $chunkData = []; $playerData = []; $timestamps = []; $masterHandler = null; $max = 0; foreach ($data->data as $history) { $tileEntities = 0; $entities = 0; $chunks = 0; $players = 0; foreach ($history->worldData as $world) { foreach ($world->chunks as $chunk) { $chunks++; } } foreach ($history->minuteReports as $mp) { $total = $mp->fullServerTick->total; $lag = $mp->fullServerTick->lagTotal; $max = max($total, $max); $timestamps[] = $mp->time; $tpsData[] = $mp->tps > 19.85 ? 20 : $mp->tps; $lagData[] = $lag; $chunkData[] = $chunks; $entData[] = $mp->ticks->entityTicks / $mp->ticks->timedTicks; $playerData[] = $mp->ticks->playerTicks / $mp->ticks->timedTicks; $aentData[] = $mp->ticks->activatedEntityTicks / $mp->ticks->timedTicks; $tentData[] = $mp->ticks->tileEntityTicks / $mp->ticks->timedTicks; } if ($history->start >= $start && $history->end <= $end) { foreach ($history->handlers as $handler) { $id = $handler->id->id; if (!isset($handlerData[$id])) { $handlerData[$id] = clone $handler; $handlerData[$id]->mergedCount = 1; } else { $handlerData[$id]->addDataFromHandler($handler); } if ($handler->id->name == "Full Server Tick") { $masterHandler = $handlerData[$id]; } } } } $tpl->handlerData = $handlerData; $tpl->js['stamps'] = $timestamps; $tpl->js['maxTime'] = $max; $tpl->js['chunkData'] = $chunkData; $tpl->js['entData'] = $entData; $tpl->js['aentData'] = $aentData; $tpl->js['tentData'] = $tentData; $tpl->js['plaData'] = $playerData; $tpl->js['lagData'] = $lagData; $tpl->js['tpsData'] = $tpsData; $tpl->js['id'] = $timings->id; $tpl->lagData = $lagData; $tpl->tpsData = $tpsData; $tpl->masterHandler = $masterHandler; }