Skip to content

v2.0.0

Latest

Choose a tag to compare

@tomloprod tomloprod released this 22 Jun 16:25
· 1 commit to main since this release
fd95ec3

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 returns int (nanoseconds) instead of float (seconds)
  • getEndTimestamp(): Now returns int (nanoseconds) instead of float (seconds)
  • setTestStartTimestamp(): Now accepts int (nanoseconds) instead of float (seconds)
  • setTestEndTimestamp(): Now accepts int (nanoseconds) instead of float (seconds)

Benefits:

  • Higher precision (nanoseconds vs microseconds)
  • Monotonic time source (unaffected by system clock changes)
  • Better performance and reliability

Removing dependency

  • The symfony/console package 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