demi/php-timelog

PHP timer for long-time operations

Installs: 35 272

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

pkg:composer/demi/php-timelog

1.0.1 2017-03-13 18:15 UTC

This package is auto-updated.

Last update: 2025-09-27 23:52:32 UTC


README

PHP timer for long-time operations

Installation

Run

composer require "demi/php-timelog" "~1.0"

Usage

For any console action:

$bigData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

$allCount = count($bigData);
$timer = new \demi\timelog\TimeLog($allCount);
$timer->showStart();
foreach ($bigData as $item) {
    // some handling start...
    sleep(rand(1, 2));
    // some handling finish...

    $timer->handled++;
    $timer->showStatus(3); // 3 - how often show status message
}
$timer->showFinish();

Output:

Starting handling: 10 items
Handled:  3/10  Remaining: 00:00:09     Speed: 0.74/sec
Handled:  6/10  Remaining: 00:00:05     Speed: 0.74/sec
Handled:  9/10  Remaining: 00:00:01     Speed: 0.75/sec

Finished after 00:00:14 Handled: 10 items