coercive/chronos

Coercive Chronos Log Utility

Installs: 1 376

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/coercive/chronos

2.0.1 2018-11-03 17:20 UTC

This package is auto-updated.

Last update: 2025-09-29 02:01:30 UTC


README

The Chronos Log Utility allows you to accurately measure the execution time of a script, and that from the server startup.

Get

composer require coercive/chronos

Usage

use Coercive\Utility\Chronos

# Monitor a sleep
Chronos::start('sleep');
sleep(2);
Chronos::stop('sleep');

# Monitor some code process
Chronos::start('sha1');
$datas = [];
foreach (range(0,1000000) as $i) {
	$datas[] = sha1($i);
}
Chronos::stop('sha1');

# Monitor an other code process
Chronos::start('concat');
foreach($datas as &$data) {
	$data .= '_add_datas_' . rand(0,1000);
}
Chronos::stop('concat');

# Monitor an other code process
Chronos::start('rand_waits');
foreach (range(0,5) as $secondes) {
	sleep($secondes);
	Chronos::lap('sleeps', 'Waiting ' . $secondes . ' secondes');
}
Chronos::stop('rand_waits');

# And now : retrieve monitoring datas !

# Full diff of all process
error_log(print_r(Chronos::diff(), true));

# Diff of sha1 process
error_log(print_r(Chronos::diff('sha1'), true));

# Diff of concat process
error_log(print_r(Chronos::diff('concat'), true));

# Retrieve full datas as array
error_log(print_r(Chronos::get(), true));