TimeWarden 2.0.0 changes
Format Change (BREAKING CHANGE)
Starting from v2.0.0, TimeWarden uses hrtime() instead of microtime() for better precision:
- Before (v1.x): Timestamps were in seconds as float (e.g.,
1496664000.019) - After (v2.x): Timestamps are in nanoseconds as int (e.g.,
1496664000019000000)
Affected methods:
getStartTimestamp(): Now returnsint(nanoseconds) instead offloat(seconds)getEndTimestamp(): Now returnsint(nanoseconds) instead offloat(seconds)setTestStartTimestamp(): Now acceptsint(nanoseconds) instead offloat(seconds)setTestEndTimestamp(): Now acceptsint(nanoseconds) instead offloat(seconds)
Benefits:
- Higher precision (nanoseconds vs microseconds)
- Monotonic time source (unaffected by system clock changes)
- Better performance and reliability
Removing dependency
- The
symfony/consolepackage is no longer required to obtain the result of table-based measurements (timeWarden()->output()).
New method: measure
- Added
measure()method that automatically handles task creation, timing, and cleanup while executing a callable and returning execution time in milliseconds
Example:
$duration = timeWarden()->measure(function() {
// Your code here
sleep(1);
processData();
});
echo "Execution took: {$duration} ms";What has changed in detail
You can see all the changes made in the following PR #10