PHPackages                             jdz/process - 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. jdz/process

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

jdz/process
===========

Utility to debug processes calculating execution time

2.0.0(5mo ago)06MITPHPPHP ^8.1

Since Jan 22Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/joffreydemetz/process)[ Packagist](https://packagist.org/packages/jdz/process)[ Docs](https://jdz.joffreydemetz.com/process/)[ RSS](/packages/jdz-process/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Process
=======

[](#process)

A PHP package for tracking the execution time of processes, sections, and subsections. This package allows you to track and format the time taken for each part of your process, providing a detailed hierarchical view of the execution time.

Features
--------

[](#features)

- Track execution time of processes, sections, and subsections
- Hierarchical structure for sections and subsections
- Formatted time output
- Easy to use API

Requirements
------------

[](#requirements)

- PHP 8.1 or higher

Installation
------------

[](#installation)

Install via Composer:

```
composer require jdz/process
```

Quick Start
-----------

[](#quick-start)

### Basic Example

[](#basic-example)

Here is a basic example of how to use the Process class to track the execution time of a process, including sections and subsections. You can find the complete example in the file examples/example.php.

```
use JDZ\Utils\Process;

$process = Process::create();

// Start the main process
$process->startSection("Main Process");

// Start a subsection
$process->startSubsection("Loading Data");
// Simulate loading data with a delay
sleep(1);
$process->endSubsection();

// Start another subsection
$process->startSubsection("Processing Data");
// Simulate processing with a delay
sleep(2);
$process->endSubsection();

// End the main section
$process->endSection();

// Get the formatted time for the entire process
echo $process->getTime(); // Example output: "3 min 3 s 234 ms"

// Export the sections and subsections in a hierarchical format
print_r($process->toArray());
```

### Example Output

[](#example-output)

When calling toArray(), it will return an array representing the process, sections, and subsections:

```
Total exec time : 3 min 3 s 234 ms
---- Main Process : 3 min 3 s 234 ms
|-- Loading Data : 1 s 234 ms
|-- Processing Data : 2 min 0 s 0 ms
```

Methods Overview
----------------

[](#methods-overview)

- **`startSection(string $name)`**: Start a new section with the given name.
- **`startSubsection(string $name, bool $endPrevious = true)`**: Start a new subsection within the current section.
- **`endSection()`**: End the current section and close all its subsections.
- **`endSubsection()`**: End the current subsection and return to the parent section.
- **`close()`**: End the process and calculate the total execution time.
- **`getTime()`**: Get the formatted time for the entire process.
- **`toArray()`**: Export the sections and their execution times as an array of formatted strings.

Time Format
-----------

[](#time-format)

The time is formatted as follows:

- **Minutes**: Only shown if greater than 0.
- **Seconds**: Only shown if greater than 0 or if minutes are shown.
- **Milliseconds**: Always shown if non-zero, or if minutes or seconds are shown.

Examples of formatted time:

- `3 min 3 s 234 ms`
- `2 s 150 ms`
- `0 ms`

Testing
-------

[](#testing)

Run the test suite:

```
# Run all tests
composer test

# Run with coverage
composer test -- --coverage-html coverage

# Run specific test file
vendor/bin/phpunit tests/ProcessItemTest.php
vendor/bin/phpunit tests/ProcessTest.php

# Run with detailed output
vendor/bin/phpunit --testdox
```

- **ProcessItemTest**: 28 tests covering all aspects of the ProcessItem class, including:

    - Construction and initialization
    - Parent-child relationships
    - Time tracking and closure
    - Hierarchical export functionality
    - Time formatting
- **ProcessTest**: 25 tests covering all aspects of the Process class, including:

    - Singleton pattern
    - Section and subsection management
    - Time tracking and formatting
    - Complex nested workflows
    - Idempotent operations

License
-------

[](#license)

This library is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

Changelog
---------

[](#changelog)

### Version 2.0.0

[](#version-200)

- Removed deprecated singleton() method in favor of create() method.
- Added Unit tests
- Improved time formatting to handle zero durations correctly.

### Version 1.0

[](#version-10)

- Initial release with core functionality for tracking process execution time, sections, and subsections.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance71

Regular maintenance activity

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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 ~319 days

Total

2

Last Release

162d ago

Major Versions

1.0.0 → 2.0.02025-12-07

PHP version history (2 changes)1.0.0PHP &gt;=8.1

2.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e83e3701566e43438525ed14578487e732b849d152b5071aa1613a0dad96913?d=identicon)[jdz](/maintainers/jdz)

---

Top Contributors

[![joffreydemetz](https://avatars.githubusercontent.com/u/15113527?v=4)](https://github.com/joffreydemetz "joffreydemetz (15 commits)")

---

Tags

debugprocessutilitiesJDZ

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jdz-process/health.svg)

```
[![Health](https://phpackages.com/badges/jdz-process/health.svg)](https://phpackages.com/packages/jdz-process)
```

###  Alternatives

[symfony/var-dumper

Provides mechanisms for walking through any arbitrary PHP variable

7.4k855.5M8.0k](/packages/symfony-var-dumper)[barryvdh/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k124.3M624](/packages/barryvdh-laravel-debugbar)[php-debugbar/php-debugbar

Debug bar in the browser for php application

4.4k21.3M40](/packages/php-debugbar-php-debugbar)[fruitcake/laravel-debugbar

PHP Debugbar integration for Laravel

19.1k662.9k29](/packages/fruitcake-laravel-debugbar)[kint-php/kint

Kint - Advanced PHP dumper

2.8k19.3M283](/packages/kint-php-kint)[tracy/tracy

😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

1.8k24.4M1.3k](/packages/tracy-tracy)

PHPackages © 2026

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