PHPackages                             tox82/server-timing-helper - 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. tox82/server-timing-helper

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

tox82/server-timing-helper
==========================

A simple helper class for Server Timing. Easily profile your code's execution time and send it to the client via the Server-Timing header.

1.3.0(1y ago)04.0k↓33.3%GPL-3.0-or-laterPHPPHP &gt;=7.0.0

Since Feb 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ToX82/server-timing-helper)[ Packagist](https://packagist.org/packages/tox82/server-timing-helper)[ RSS](/packages/tox82-server-timing-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)DependenciesVersions (9)Used By (0)

Server Timing Helper
====================

[](#server-timing-helper)

A Simple Tool for Benchmarking Your PHP Code
--------------------------------------------

[](#a-simple-tool-for-benchmarking-your-php-code)

The `ServerTiming` class is designed to assist developers in measuring and logging the execution time of various code segments within a PHP application. By utilizing this class, you can initiate and terminate timers for different metrics, transmit these metrics to the client via the Server-Timing header, and record the results to a file. This is particularly useful for performance monitoring and optimization.

[![server-timing](https://user-images.githubusercontent.com/659492/216758847-673f1155-db52-48a8-aada-3648b7c837cf.png)](https://user-images.githubusercontent.com/659492/216758847-673f1155-db52-48a8-aada-3648b7c837cf.png)

This tool is based on the [Server Timing](https://www.w3.org/TR/server-timing/) specification. You can learn more about it on [web.dev](https://web.dev/custom-metrics/?utm_source=devtools#server-timing-api).

Installation:
=============

[](#installation)

---

```
composer require tox82/server-timing-helper
```

Usage
=====

[](#usage)

---

The profile Method
------------------

[](#the-profile-method)

This is the easiest way to use the `ServerTiming` class. It automatically handles the start/stop methods, and logs the results to the `Network/Timing` panel in your browser's `DevTools`.

```
\Tox82\ServerTiming::profile('metricName');
# ... your code here ...
\Tox82\ServerTiming::profile('metricName');
```

The start/stop Method
---------------------

[](#the-startstop-method)

Alternatively, you can manually control the start and stop methods by using `start/stop` instead of `profile`:

```
\Tox82\ServerTiming::start('metricName');
# ... your code here ...
\Tox82\ServerTiming::stop('metricName');
```

Saving the Output to a Log File
-------------------------------

[](#saving-the-output-to-a-log-file)

The `log` method enables you to write detailed log entries for your metrics to a file. This requires you to have a valid, writeable log file, but IMO it makes it a little bit easier to read the metrics. You can use nested blocks to log the execution time of specific parts of your code. My suggestion is to add some spaces to the beginning of the nested blocks to make it more readable.

```
\Tox82\ServerTiming::log('heavyBlocks');
# foreach ($items as $item) {
\Tox82\ServerTiming::log('    singleBlock');
# ... your code here ...
\Tox82\ServerTiming::log('    singleBlock');
# }
\Tox82\ServerTiming::log('heavyBlocks');
```

[![server_timing](https://private-user-images.githubusercontent.com/659492/351765982-e8c46310-1671-4239-86a6-7da293e5d371.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ4NTA4MzAsIm5iZiI6MTc3NDg1MDUzMCwicGF0aCI6Ii82NTk0OTIvMzUxNzY1OTgyLWU4YzQ2MzEwLTE2NzEtNDIzOS04NmE2LTdkYTI5M2U1ZDM3MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMzMFQwNjAyMTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zMGEzNzFmNDgxNzgzMjk5ZjhjYjJkMWZhNGUyOTc0ODA5MWVjZTdkZGZkNGM2MDA1MmFmYTk4ZjFjYTJjMTBhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.PXqqaXYZSQ_5fKEkrreIRA7RK0R9celn9n-6PchOog8)](https://private-user-images.githubusercontent.com/659492/351765982-e8c46310-1671-4239-86a6-7da293e5d371.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzQ4NTA4MzAsIm5iZiI6MTc3NDg1MDUzMCwicGF0aCI6Ii82NTk0OTIvMzUxNzY1OTgyLWU4YzQ2MzEwLTE2NzEtNDIzOS04NmE2LTdkYTI5M2U1ZDM3MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwMzMwJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDMzMFQwNjAyMTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0zMGEzNzFmNDgxNzgzMjk5ZjhjYjJkMWZhNGUyOTc0ODA5MWVjZTdkZGZkNGM2MDA1MmFmYTk4ZjFjYTJjMTBhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.PXqqaXYZSQ_5fKEkrreIRA7RK0R9celn9n-6PchOog8)

Setting a Custom Log File
-------------------------

[](#setting-a-custom-log-file)

By default, `Server Timing Helper` attempts to find the apache error\_log file path for logging. However, you can specify a custom log file path using the `setLogFile` method. Make sure to set the log file path before using the `log` method.

```
\Tox82\ServerTiming::setLogFile('/var/www/server_timing.log');
```

Resources
=========

[](#resources)

---

- [Report issues](https://github.com/ToX82/server-timing-helper/issues)
- [Send Pull Requests](https://github.com/ToX82/server-timing-helper/pulls)
- [Check the main repository](https://github.com/ToX82/server-timing-helper)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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.

###  Release Activity

Cadence

Every ~76 days

Recently: every ~119 days

Total

8

Last Release

654d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c5693ca56618fba49dba25112105abb77764c3ad57106fa310babbdffa34ad97?d=identicon)[ToX82](/maintainers/ToX82)

---

Top Contributors

[![ToX82](https://avatars.githubusercontent.com/u/659492?v=4)](https://github.com/ToX82 "ToX82 (12 commits)")

---

Tags

phpperformancedebuggingprofilingMetricsbenchmarkingServer-Timingtiming

### Embed Badge

![Health badge](/badges/tox82-server-timing-helper/health.svg)

```
[![Health](https://phpackages.com/badges/tox82-server-timing-helper/health.svg)](https://phpackages.com/packages/tox82-server-timing-helper)
```

###  Alternatives

[laracraft-tech/laravel-xhprof

Easy XHProf setup to profile your laravel application!

235321.4k](/packages/laracraft-tech-laravel-xhprof)[koriym/xdebug-mcp

Universal PHP Xdebug MCP Server with AI-optimized debugging support

4011.6k1](/packages/koriym-xdebug-mcp)[jbzoo/jbdump

Script for debug and dump PHP variables and other stuff. This tool is a nice replacement for print\_r() and var\_dump() functions.

211.1M3](/packages/jbzoo-jbdump)[bavix/laravel-xhprof

Quick profiling of your code for Laravel

22156.6k](/packages/bavix-laravel-xhprof)[wikimedia/arc-lamp

Flame graphs and log processing for PHP stack traces.

434.4k](/packages/wikimedia-arc-lamp)

PHPackages © 2026

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