<commit_before><?php
/**
 * Bukkit Timings Parser
 *
 * Written by Aikar <<EMAIL>>
 *
 * This file originally started out as an extremely quick hackjob... So quality isn't the best
 * but it works.
 *
 * This is now the legacy parser, since the new format is so different and the UI won't work for
 * old data set, we will keep this here for legacy files.
 *
 * @license MIT
 */

if (!defined('TIMINGS_ENV')) {
	die;
}
global $legacyData;


$spigotConfigPattern = "/&amp;amp;lt;spigotConfig&amp;amp;gt;(.*)&amp;amp;lt;\\/spigotConfig&amp;amp;gt;/ms";
if (preg_match($spigotConfigPattern, $legacyData, $configMatch)) {
	$spigotConfig = $configMatch[1];
	$legacyData = preg_replace($spigotConfigPattern, "", $legacyData);
}
if (preg_match('/Sample time (.+?) \(/', $legacyData, $sampm)) {
	$sample = $sampm[1];
}
$subkey = 'Minecraft - Breakdown (counted by other timings, not included in total)  ';
$report = array($subkey => array());
$current = null;
$version  = '';
if (preg_match('/# Version (git-Spigot-)?(.*)/i', $legacyData, $m)) {
	$version = $m[2];
}
$highEntityTick = false;

// legacy
$exclude = array('entityAIJump', 'entityAILoot', 'entityAIMove',
	'entityTickRest', 'entityAI', 'entityBaseTick');
foreach (explode("\n", $legacyData) as $line) {
	if (empty($line)) continue;
	if ($line[0] != " " && $line[0] != "#") {
		$plugin = $line;
		if ($plugin == 'Custom Timings' || $plugin == "Minecraft - ** indicates it&#39;s already counted by another timing") {
			$plugin = 'Minecraft';
		}
		$report[$plugin] = array();
		$current =& $report[$plugin];
	} else if ($line[0] == " ") {
		if (preg_match("/(.+?) Time: (\\d+) Count: (\\d+) Avg: /", $line, $m)) {
			array_shift($m);

			$active =& $current;
			$m[0] = trim($m[0]);
			if ($m[0] == 'Player Tick' || $m[0] == 'Connection Handler') {
				$m[0] = '** Connection Handler';
			}
			if (isset($_GET['dev'])) {
				//print_r($m);
			}
			if (preg_match("/Plugin: (.*) Event:(.*)/", $m[0], $eventmatch)) {
				$xplugin = $eventmatch[1];
				$m[0] = trim($eventmatch[2]);
				$active =& $report[trim($xplugin)];
			}
			if (preg_match("/Task: (.*) Runnable: (.*)/", $m[0], $taskmatch)) {
				$xplugin = $taskmatch[1];
				$m[0] = 'Task: ' . str_replace(':', ' ', preg_replace('/.*? Id\:\((.*)\)/', '\1', $taskmatch[2]));

				if (preg_match('/.*\.(.*)$/', $m[0], $cleanmatch)) {
					$m[0] = "Task: " . $cleanmatch[1];
				}
				$active =& $report[trim($xplugin)];
			}

			$data = array(@$m[1], $m[2]);
			if (!in_array($m[0], $exclude) && substr($m[0], 0, 2) != "**") {
				if (!isset($current[@$m[0]])) {
					$active[$m[0]] = $data;
				} else {
					$active[$m[0]][0] += $m[1];
					$active[$m[0]][1] += $m[2];
				}
				$tasks = '** Tasks';
				if (substr($m[0], 0, 5) == "Task:") {
					if (!isset($report[$subkey][$tasks])) {
						$report[$subkey][$tasks] = $data;
					} else {
						$report[$subkey][$tasks][0] += $m[1];
						$report[$subkey][$tasks][1] += $m[2];
					}
				}
				$active['Total'] += $m[1];
			} else {
				if (!isset($report[$subkey][$m[0]])) {
					$report[$subkey][$m[0]] = $data;
				} else {
					$report[$subkey][$m[0]][0] += $m[1];
					$report[$subkey][$m[0]][1] += $m[2];
				}
			}
		}
	}
}
$report[$subkey]['Total'] = intval($report['Minecraft']['Total']) - 1;


$total = 0;
$numTicks = 0;
$entityTicks = 0;
$playerTicks = 0;
$totalTimings = 0;<commit_msg>more notice issues<commit_after><?php
/**
 * Bukkit Timings Parser
 *
 * Written by Aikar <<EMAIL>>
 *
 * This file originally started out as an extremely quick hackjob... So quality isn't the best
 * but it works.
 *
 * This is now the legacy parser, since the new format is so different and the UI won't work for
 * old data set, we will keep this here for legacy files.
 *
 * @license MIT
 */

if (!defined('TIMINGS_ENV')) {
	die;
}
global $legacyData;


$spigotConfigPattern = "/&amp;amp;lt;spigotConfig&amp;amp;gt;(.*)&amp;amp;lt;\\/spigotConfig&amp;amp;gt;/ms";
if (preg_match($spigotConfigPattern, $legacyData, $configMatch)) {
	$spigotConfig = $configMatch[1];
	$legacyData = preg_replace($spigotConfigPattern, "", $legacyData);
}
if (preg_match('/Sample time (.+?) \(/', $legacyData, $sampm)) {
	$sample = $sampm[1];
}
$subkey = 'Minecraft - Breakdown (counted by other timings, not included in total)  ';
$report = array($subkey => array('Total' => 0), 'Minecraft' => array('Total' => 0));
$current = null;
$version  = '';
if (preg_match('/# Version (git-Spigot-)?(.*)/i', $legacyData, $m)) {
	$version = $m[2];
}
$highEntityTick = false;

// legacy
$exclude = array('entityAIJump', 'entityAILoot', 'entityAIMove',
	'entityTickRest', 'entityAI', 'entityBaseTick');
foreach (explode("\n", $legacyData) as $line) {
	if (empty($line)) continue;
	if ($line[0] != " " && $line[0] != "#") {
		$plugin = $line;
		if ($plugin == 'Custom Timings' || $plugin == "Minecraft - ** indicates it&#39;s already counted by another timing") {
			$plugin = 'Minecraft';
		}
		$report[$plugin] = array();
		$current =& $report[$plugin];
	} else if ($line[0] == " ") {
		if (preg_match("/(.+?) Time: (\\d+) Count: (\\d+) Avg: /", $line, $m)) {
			array_shift($m);

			$active =& $current;
			$m[0] = trim($m[0]);
			if ($m[0] == 'Player Tick' || $m[0] == 'Connection Handler') {
				$m[0] = '** Connection Handler';
			}
			if (isset($_GET['dev'])) {
				//print_r($m);
			}
			if (preg_match("/Plugin: (.*) Event:(.*)/", $m[0], $eventmatch)) {
				$xplugin = $eventmatch[1];
				$m[0] = trim($eventmatch[2]);
				$active =& $report[trim($xplugin)];
			}
			if (preg_match("/Task: (.*) Runnable: (.*)/", $m[0], $taskmatch)) {
				$xplugin = $taskmatch[1];
				$m[0] = 'Task: ' . str_replace(':', ' ', preg_replace('/.*? Id\:\((.*)\)/', '\1', $taskmatch[2]));

				if (preg_match('/.*\.(.*)$/', $m[0], $cleanmatch)) {
					$m[0] = "Task: " . $cleanmatch[1];
				}
				$active =& $report[trim($xplugin)];
			}

			$data = array(@$m[1], $m[2]);
			if (!in_array($m[0], $exclude) && substr($m[0], 0, 2) != "**") {
				if (!isset($current[@$m[0]])) {
					$active[$m[0]] = $data;
				} else {
					$active[$m[0]][0] += $m[1];
					$active[$m[0]][1] += $m[2];
				}
				$tasks = '** Tasks';
				if (substr($m[0], 0, 5) == "Task:") {
					if (!isset($report[$subkey][$tasks])) {
						$report[$subkey][$tasks] = $data;
					} else {
						$report[$subkey][$tasks][0] += $m[1];
						$report[$subkey][$tasks][1] += $m[2];
					}
				}
				if (!empty($m[1])) {
					@$active['Total'] += $m[1];
				}
			} else {
				if (!isset($report[$subkey][$m[0]])) {
					$report[$subkey][$m[0]] = $data;
				} else {
					$report[$subkey][$m[0]][0] += $m[1];
					$report[$subkey][$m[0]][1] += $m[2];
				}
			}
		}
	}
}
$report[$subkey]['Total'] = intval(@$report['Minecraft']['Total']) - 1;


$total = 0;
$numTicks = 0;
$entityTicks = 0;
$playerTicks = 0;
$totalTimings = 0;
{'fraction_non_alphanumeric': 0.26032632662060856, 'fraction_numerical': 0.01837424665588711, 'mean_word_length': 3.6634681288553805, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '572151', 'n_tokens_mistral': 3106, 'n_tokens_neox': 2701, 'n_words': 549}