mibexx / php-time-tracking
Tracks php execution time
1.1.1
2020-02-28 13:17 UTC
Requires
- php: >7.1
Requires (Dev)
- codeception/codeception: ^4.1
- symfony/var-dumper: ^5.0
This package is auto-updated.
Last update: 2025-03-29 00:43:31 UTC
README
Tracks execution time in php applications.
Init
use Mibexx\TimeTracking\Adapter\TimeTracking; TimeTracking::init();
Usage
use Mibexx\TimeTracking\Adapter\TimeTracking; TimeTracking::track('First'); usleep(1000000); TimeTracking::track('Second'); usleep(1200000); TimeTracking::stop(); TimeTracking::track('Second'); usleep(1300000); TimeTracking::stop(); TimeTracking::track('Third'); usleep(1400000); TimeTracking::track('Fourth'); usleep(1500000); TimeTracking::stop(); TimeTracking::stop(); TimeTracking::stop();
Get Results
use Mibexx\TimeTracking\Adapter\TimeTracking; $trackingResults = TimeTracking::getTrackings(); echo '<table border="1" cellpadding="10"><thead><th align="left">Function</th><th align="right">Counter</th><th align="right">Times</th></thead><tbody>'; foreach ($trackingResults as $ident => $results) { echo sprintf( '<tr><td>%s</td><td align="right">%s</td><td align="right"><ul><li>%s</li></ul></td></tr>', $ident, count($results['trackings']), implode('</li><li>', array_column($results['trackings'], 'time')) ); } echo '</tbody></table>';