Componette

Componette

netpromotion

netpromotion / profiler v1.4.0-rc2

Profiler with adapter for Tracy

download-cloud-line composer require netpromotion/profiler

Profiler with adapter for Tracy

This repository contains lightweight, very quick and easy to use Profiler with adapter for Tracy.

Usage

If you wish to profile a block of code, simply encapsulate it between Profiler::start and Profiler::finish calls.

<?php // index.php

if (/* Is debug mode enabled? */) {
    Profiler::enable();
}

Profiler::start();
require(__DIR__ . "/required_file.php");
Profiler::finish();
<?php // required_file.php

// If you wish to use default labels, call functions without parameters
Profiler::start(/* sprintf("%s#%s", __FILE__, __LINE__) */);
/* your code goes here */
Profiler::finish(/* sprintf("%s#%s", __FILE__, __LINE__) */);

// If you wish to use static labels, place label as first parameter
Profiler::start("static label");
/* your code goes here */
Profiler::finish("static label");

// If you wish to use dynamic labels, call functions like sprintf
Profiler::start(/* sprintf( */ "line %s", __LINE__ /* ) */);
/* your code goes here */
Profiler::finish(/* sprintf( */ "line %s", __LINE__ /* ) */);

// If you wish to create more detailed profiles, start new profile inside another one
Profiler::start("Profile 1");
    /* your code goes here */
    Profiler::start("Profile 1.1");
        Profiler::start("Profile 1.1.1");
            /* your code goes here */
        Profiler::finish("Profile 1.1.1");
        /* your code goes here */
        Profiler::start("Profile 1.1.2");
            /* your code goes here */
        Profiler::finish("Profile 1.1.2");
        /* your code goes here */
    Profiler::finish("Profile 1.1");
Profiler::finish("Profile 1");

If you wish to know more about Profiler, please visit Profiler's README.md.

How to install

Run composer require netpromotion/profiler in your project directory.

Adapter for Tracy

Add extension Netpromotion\Profiler\Extension\ProfilerNetteExtension into your configuration, it is not necessary to call Profiler::enable.

extensions:
    profiler: Netpromotion\Profiler\Extension\ProfilerNetteExtension

If you wish to profile before the container is ready, call Profiler::enable manually.

Configuration

profiler:
    profile:
        createService: false  # or true
    bar:
        primaryValue: effective  # or absolute
        show:
            memoryUsageChart: true  # or false
            shortProfiles: true  # or false
            timeLines: true  # or false

There is a live demo available - run make demo and click here.

Lumen, pure PHP and everything else

Add panel Netpromotion\Profiler\Adapter\TracyBarAdapter to your bar via Bar::addPanel method manually or use netpromotion/tracy-wrapper.

tracy_wrap(function() {
    /* your code goes here */
}, [new TracyBarAdapter([
    "primaryValue" => "effective", // or "absolute"
    "show" => [
        "memoryUsageChart" => true, // or false
        "shortProfiles" => true, // or false
        "timeLines" => true // or false
    ]
])]);

There is a live demo available - run make demo and click here.

  • v1.4.0-rc2

  • v1.4.0-rc1

  • v1.3.0 Added base configuration options

    profiler:
        profile:
            createService: false  # or true
        bar:
            primaryValue: effective  # or absolute
            show:
                memoryUsageChart: true  # or false
                shortProfiles: true  # or false
                timeLines: true  # or false
  • v1.2.2

  • v1.2.1 Added base configuration options

    profiler:
        profile:
            createService: false  # or true
        bar:
            primaryValue: effective  # or absolute
            show:
                memoryUsageChart: true  # or false
                shortProfiles: true  # or false
                timeLines: true  # or false
  • v1.2.0

  • v1.1.3

  • v1.1.2 Soft require for tracy/tracy

  • v1.1.1

  • v1.1.0 Added ProfilerService

    WARNING: ProfilerNetteExtension::enable is deprecated

  • v1.0.3

  • v1.0.2

  • v1.0.1 Added timeline

    See #2

  • v1.0.0

  • v1.0.0-rc4

  • v1.0.0-rc3

  • v1.0.0-rc2

  • v1.0.0-rc1

bar-chart-fill

Statistics

download-cloud-fill
72772
star-fill
31
bug-fill
1
flashlight-fill
7.3y
price-tag-2-line

Badges

guide-fill

Dependencies

Componette Componette felix@nette.org