Why Stopwatch? โ
A request feels slow and the log says how long it took, not where the time went. Stopwatch answers the second question: mark a few points along the path, and read the gaps between them.
php
stopwatch()->withQueryTracking()->start();
$users = User::all();
stopwatch()->checkpoint('Load users');
$orders = Order::where('status', 'pending')->get();
stopwatch()->checkpoint('Load orders');
stopwatch()->toLog('Profile:');
// Profile:
// [3ms / 3ms] Load users (queries=1)
// [12ms / 15ms] Load orders (queries=1)
// Total: 15msUse it when a request, command, or job feels slow and you would rather not stand up an APM to find out why. It runs in tests and CI as well as in production.
What it is not โ
An APM. There is no aggregation across requests, no service map, no alerting on trends. Stopwatch profiles the run in front of you, and the run log keeps the last few so you can read them after the fact.
Compatibility โ
PHP 8.3+ ยท Laravel 12.x / 13.x. The profiler core runs without Laravel; query tracking, the toolbar, and the run log do not.