<commit_before><?php
require_once('../src/Timer.php');

use \Xicrow\DebugTools\Timer;
?>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Xicrow/DebugTools/Timer</title>
		<style type="text/css">
			pre {
				margin: 5px;
				padding: 0;
				font-family: Consolas, Courier, monospace;
			}
		</style>
	</head>

	<body>
		<?php
		// Set project document root
		Timer::$documentRoot = 'E:\\GitHub\\';

		// Set default options
		Timer::$defaultOptions['getStats']['timestamp']      = false;
		Timer::$defaultOptions['getStats']['nested']         = true;
		Timer::$defaultOptions['getStats']['oneline']        = true;
		Timer::$defaultOptions['getStats']['oneline_length'] = 50;

		// Start "Total" timer
		Timer::start('Total');

		// No name test
		Timer::start();
		Timer::stop();

		// Default timers
		Timer::start('Sleep');
		sleep(1);
		Timer::stop();

		// Loop timers
		for ($i = 1; $i <= 2; $i++) {
			Timer::start('Loop level 1');
			for ($j = 1; $j <= 2; $j++) {
				Timer::start('Loop level 2');
				for ($k = 1; $k <= 2; $k++) {
					Timer::start('Loop level 3');

					Timer::stop();
				}
				Timer::stop();
			}
			Timer::stop();
		}

		// Callback timers
		Timer::callback(null, 'strpos', 'Hello world', 'world');
		Timer::callback(null, 'array_sum', [1, 2, 3, 4, 5, 6, 7, 8, 9]);
		Timer::callback(null, 'min', [1, 2, 3, 4, 5, 6, 7, 8, 9]);
		Timer::callback(null, 'max', [1, 2, 3, 4, 5, 6, 7, 8, 9]);
		Timer::callback(null, ['nonExistingClass', 'nonExistingMethod'], 'param1', 'param2');
		Timer::callback(null, function () {
			return 'closure';
		});

		// Custom timers
		Timer::custom('-5 minutes', strtotime('-5minutes'), time());
		Timer::custom('+5 minutes', time(), strtotime('+5minutes'));

		// Stop "Total" timer
		Timer::stop();

		// Show all timers
		Timer::showAll();

		echo '<hr />';
		echo '<pre>' . print_r(Timer::$timers, true) . '</pre>';
		?>
	</body>
</html><commit_msg>Update timer demo<commit_after><?php
$scriptStart = microtime(true);

$requireStart = microtime(true);
require_once('../src/Debugger.php');
require_once('../src/Collection.php');
require_once('../src/Timer.php');
$requireStop = microtime(true);

use \Xicrow\DebugTools\Timer;
use \Xicrow\DebugTools\Debugger;

// Set debugger options
Debugger::$documentRoot   = 'E:\\GitHub\\';
Debugger::$showCalledFrom = false;

/**
 * Debugger utility functions
 */
function debug($data) {
	return Debugger::debug($data);
}

/**
 * Timer utility functions
 */
function timerStart($key = null) {
	return Timer::start($key);
}

function timerStop($key = null) {
	return Timer::stop($key);
}

function timerCustom($key = null, $start = null, $stop = null) {
	return Timer::custom($key, $start, $stop);
}

function timerCallback($key = null, $callback) {
	return Timer::callback($key, $callback);
}

function timerShow($key = null, $options = []) {
	return Timer::show($key, $options);
}

function timerShowAll($options = []) {
	return Timer::showAll($options);
}

?>
<html>
	<head>
		<meta charset="UTF-8">
		<title>Xicrow/DebugTools/Timer</title>
		<style type="text/css">
			pre {
				margin: 5px;
				padding: 0;
				font-family: Consolas, Courier, monospace;
			}
		</style>
	</head>

	<body>
		<?php
		// Only add "ALL" and "PHP boostrap" timer, if we have request time in float, otherwise it is unusable
		if (isset($_SERVER['REQUEST_TIME_FLOAT'])) {
			Timer::custom('ALL', $_SERVER['REQUEST_TIME_FLOAT']);
			Timer::custom('PHP bootstrap', $_SERVER['REQUEST_TIME_FLOAT'], $scriptStart);
		}
		Timer::custom('script', $scriptStart);
		Timer::custom('require files', $requireStart, $requireStop);

		// No name test
		Timer::start();
		Timer::stop();

		// Loop timers
		for ($i = 1; $i <= 2; $i++) {
			Timer::start('Loop level 1');
			for ($j = 1; $j <= 2; $j++) {
				Timer::start('Loop level 2');
				for ($k = 1; $k <= 2; $k++) {
					Timer::start('Loop level 3');
					Timer::stop();
				}
				Timer::stop();
			}
			Timer::stop();
		}

		// Callback timers
		Timer::callback(null, 'strpos', 'Hello world', 'world');
		Timer::callback(null, 'array_sum', [1, 2, 3, 4, 5, 6, 7, 8, 9]);
		Timer::callback(null, 'min', [1, 2, 3, 4, 5, 6, 7, 8, 9]);
		Timer::callback(null, 'max', [1, 2, 3, 4, 5, 6, 7, 8, 9]);
		Timer::callback(null, ['Xicrow\DebugTools\Debugger', 'debug'], [1, 2, 3]);
		Timer::callback(null, function () {
			return true;
		});

		// Custom timers
		Timer::custom('-5 minutes', strtotime('-5minutes'), time());
		Timer::custom('+5 minutes', time(), strtotime('+5minutes'));

		// Show all timers
		Timer::showAll();
		?>
	</body>
</html>
{'fraction_non_alphanumeric': 0.2187362878455463, 'fraction_numerical': 0.020623080298376482, 'mean_word_length': 3.8811563169164884, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 32, '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': '54890', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1623, 'n_words': 389}