PHPackages                             zdenekdrahos/profiler-tools - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. zdenekdrahos/profiler-tools

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

zdenekdrahos/profiler-tools
===========================

Helper functions - stopwatch, logger and time converter (seconds to readable string)

v1.2.0(11y ago)01.9kMITPHPPHP &gt;=5.3.0

Since Feb 1Pushed 11y ago1 watchersCompare

[ Source](https://github.com/zdenekdrahos/profiler-tools)[ Packagist](https://packagist.org/packages/zdenekdrahos/profiler-tools)[ RSS](/packages/zdenekdrahos-profiler-tools/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Simple PHP Profiler Tools
=========================

[](#simple-php-profiler-tools)

Stopwatch, CSV logger and time converter (seconds to readable string).

Install
-------

[](#install)

Put this in a `composer.json`:

```
{
    "require": {
        "zdenekdrahos/profiler-tools": "*"
    }
}
```

Usage
-----

[](#usage)

```
// start stopwatch
$stopwatch = ProfilerTools\stopwatch();

// execute something

// stop timer
list($start, $end, $elapsedSeconds) = $stopwatch();

// log execution time
appendCsvLine(
    'log.csv'
    array(
        $start->format('c'),
        $end->format('c'),
        ProfilerTools\secondsToDays($elapsedSeconds)
    )
);
```

Logger appends following line to `log.csv`:

```
2015-02-01T09:15:17+01:00,2015-02-01T09:15:18+01:00,1.1s

```

### No temporal coupling

[](#no-temporal-coupling)

`execute something` is the tricky part of the previous example. You could get easily coupled to start and stop stopwatch. You can use passing closure to `monitorExecution`which returns [execution report](src/ExecutionReport.php). Take a look at example with *hidden* stopwatch:

```
$report = ProfilerTools\monitorExecution(function() {
    // execute something
});
ProfilerTools\appendCsvLine('log.csv', array(
    $report->dateStart->format('c'),
    $report->dateFinish->format('c'),
    $report->convertSecondsToReadableString(),
    $report->elapsedSeconds,
    $report->hasFailed() ? $report->exception->getMessage() : ''
));
```

Stopwatch
---------

[](#stopwatch)

- `$stopwatch = ProfilerTools\stopwatch()` - starts timer and returns function for stopping timer
- `$stopwatch()` - returns start/end date and elapsed seconds
- `$report = ProfilerTools\monitorExecution(closure)` - monitors function call and returns report

Logger
------

[](#logger)

- `ProfilerTools\appendCsvLine($file, array $row)` - converts array to line and append the line
- `ProfilerTools\appendCsvLines($file, array $rows)` - appends N lines in one write operation
- `ProfilerTools\clearLog($file)` - deletes existing content of file

Time converter
--------------

[](#time-converter)

- `ProfilerTools\secondsToDays($elapsedSeconds, $precision)` - converts seconds to readable format, optional milliseconds precions

### Examples

[](#examples)

Seconds.00s.0s0.15464560.15s0.2s99s9s19.787819.79s19.8s651m 5s1m 5s3746m 14s6m 14s12805.93h 33m 25.9s3h 33m 25.9s86922.2981d 8m 42.3s1d 8m 42.3sLicense
-------

[](#license)

Copyright (c) 2015 Zdeněk Drahoš. MIT Licensed, see [LICENSE](LICENSE) for details.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~7 days

Total

3

Last Release

4157d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7994022?v=4)[Zdeněk Drahoš](/maintainers/zdenekdrahos)[@zdenekdrahos](https://github.com/zdenekdrahos)

---

Top Contributors

[![zdenekdrahos](https://avatars.githubusercontent.com/u/7994022?v=4)](https://github.com/zdenekdrahos "zdenekdrahos (26 commits)")

---

Tags

profilerloggerbenchmarkstopwatchtime converter

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zdenekdrahos-profiler-tools/health.svg)

```
[![Health](https://phpackages.com/badges/zdenekdrahos-profiler-tools/health.svg)](https://phpackages.com/packages/zdenekdrahos-profiler-tools)
```

###  Alternatives

[blackfire/php-sdk

Blackfire.io PHP SDK

16013.1M40](/packages/blackfire-php-sdk)[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3511.6M24](/packages/analog-analog)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2111.2M2](/packages/marvinlabs-laravel-discord-logger)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1861.6M3](/packages/justbetter-magento2-sentry)[inpsyde/wonolog

Monolog-based logging package for WordPress.

184637.3k7](/packages/inpsyde-wonolog)[amphp/log

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

402.9M82](/packages/amphp-log)

PHPackages © 2026

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