PHPackages                             emoretti/kronos - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. emoretti/kronos

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

emoretti/kronos
===============

Kronos is a PHP library, which allows to calculate the execution time of a page and code blocks (called CheckPoint), with an accuracy up to 1 μs

035PHP

Since Mar 27Pushed 8y agoCompare

[ Source](https://github.com/emoretticom/kronos)[ Packagist](https://packagist.org/packages/emoretti/kronos)[ RSS](/packages/emoretti-kronos/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Kronos - calculate the execution time of a page and code blocks for PHP
=======================================================================

[](#kronos---calculate-the-execution-time-of-a-page-and-code-blocks-for-php)

Kronos is a PHP library, which allows to calculate the execution time of a page and code blocks (called CheckPoint), with an accuracy up to 1 μs

Installation
------------

[](#installation)

Install the latest version with

```
$ composer require emoretti/kronos ^dev-master
```

Report Example
--------------

[](#report-example)

[![alt text](https://camo.githubusercontent.com/01ac364d2381d28feca48b781b4f5b8673ef43491880b68070c8087b28ae2181/687474703a2f2f7777772e6574746f72656d6f72657474692e636f6d2f494d475f5245504f2f6b726f6e6f732e706e67)](https://camo.githubusercontent.com/01ac364d2381d28feca48b781b4f5b8673ef43491880b68070c8087b28ae2181/687474703a2f2f7777772e6574746f72656d6f72657474692e636f6d2f494d475f5245504f2f6b726f6e6f732e706e67)

Configuration
-------------

[](#configuration)

`no configuration needed`

Basic Usage
-----------

[](#basic-usage)

Create an instance of `Kronos()` class in the start of your page, passing the page "alias" name and `optionally` the initial float timestamp (If not passed kronos calculate for you the timestamp).
At the end of page call the method `setMainEnd()` optionally passing the ending float timestamp (If not passed kronos calculate for you the timestamp).
Finally you can call the method `getReport()` to render under your page a final report, or call the method `getReportRaw()` to get the array with all the data.
The `getReport()` accept in input a dateFormat in PHP style,

```

```

Use of checkpoints
------------------

[](#use-of-checkpoints)

After declare the instance of `Kronos()`

In the middle of your code (where you want), you can insert a checkpoint, which allows you to create other statistics.
To create a checkpoint use the methods `startCheckPoints()` and `stopCheckPoints()` passing the checkpoint alias (it will be the key of your checkpoint), and optionally the float timestamp (If not passed kronos calculate for you the timestamp).

```

```

Kronos Results
--------------

[](#kronos-results)

Kronos results can be:

1. Rendered in bottom of the examined page

    ```
    	$myKronos->getReport();
    ```
2. Returned in array structure (or json if you pass the first argument true)

    ```
    	\\Array structure output
    	$myKronos->getReportRaw();
    	\\Json structure output
    	$myKronos->getReportRaw(true);
    ```
3. Saved in a file (the file will have a json inside)

    ```
    	$myKronos->saveReportData(__DIR__ . "/report.json");
    ```

    If you save data for get the report later, you can render that use the static method `Kronos::renderReport()` passing $reportName and $reportData

    ```
    	use emoretti\kronos\Kronos;
    	require_once("src/Kronos.php");
    	Kronos::renderReport("TestReport", file_get_contents(__DIR__."/report.json"));
    ```

Kronos Render
-------------

[](#kronos-render)

Kronos will render the data through is template engine `KronosTemplate()`, by default the template is: `src/template/KronosTemplate.php` (it use Bootstrap.min.css) , you can modify it as you want ( Be careful not to change the variable names in the template)

You can specify your prefered date format for those methods:

1. getReport ( $dateFormat = "d/m/Y H:i:s:u" )
2. getReportRaw ( $json= false , $dateFormat = "d/m/Y H:i:s:u" )
3. renderReport( $name , $data , $dateFormat='d/m/Y H:i:s:u' )

Kronos time execution
---------------------

[](#kronos-time-execution)

Kronos will try automatically to determine his execution time, it will be presented automatically in the final report, may be usefull to determine how time it is used by the class itself.
N.B. Kronos attempts to calculate its execution time. But these times are to be considered as APPROXIMATE. Remember that : 0.001 ms == 1 µs (In 1 μs the light runs exactly 299.792458 meters).

### Author

[](#author)

Ettore Moretti -  -  -

### License

[](#license)

href-count is licensed under the MIT License - see the `LICENSE` file for details

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/87b85af334de422bf9c218643c13655627c2204f930f68148c3a3c3fbe607a3d?d=identicon)[emoretticom](/maintainers/emoretticom)

---

Top Contributors

[![emoretticom](https://avatars.githubusercontent.com/u/37150171?v=4)](https://github.com/emoretticom "emoretticom (9 commits)")

### Embed Badge

![Health badge](/badges/emoretti-kronos/health.svg)

```
[![Health](https://phpackages.com/badges/emoretti-kronos/health.svg)](https://phpackages.com/packages/emoretti-kronos)
```

###  Alternatives

[symfony/stopwatch

Provides a way to profile code

2.8k387.2M918](/packages/symfony-stopwatch)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[spatie/ignition

A beautiful error page for PHP applications.

510147.6M69](/packages/spatie-ignition)[jokkedk/webgrind

Webgrind is a Xdebug profiling web frontend in PHP5. It implements a subset of the features of kcachegrind and installs in seconds and works on all platforms. For quick'n'dirty optimizations it does the job.

3.3k193.0k](/packages/jokkedk-webgrind)[koriym/printo

An object graph visualizer.

1421.8M2](/packages/koriym-printo)[soloterm/dumps

A Laravel command to intercept dumps from your Laravel application.

125285.7k3](/packages/soloterm-dumps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
