Skip to content

Config point label R trim

Bart van Hoekelen edited this page Apr 26, 2017 · 2 revisions

Tables of contents

Purpose

You can specify the right characters you want to strip from the point label.

Related config item Config::setPointLabelLTrim()

Code

// Add namespace at the top 
use Performance\Config;

// Set config
Config::setPointLabelRTrim('stringAsMasker');
Config:: setPointLabelRTrim($mask);
Item Type Accept Default Required
$mask string 'mask' false yes

Exemple

Note: pay attention on the point label name.

Normal state

PHP performance tool - Config::POINT_LABEL_RTRIM without mask

With config item

PHP performance tool - Config::POINT_LABEL_RTRIM with mask

Code fragment

use Performance\Performance;
use Performance\Config;

// Bootstrap class
$foo = new Foo();

class Foo
{
    public function __construct()
    {
        // You can specify the characters you want to strip
        Config::setPointLabelLTrim('synchronize');
        Config::setPointLabelRTrim('Run');

        $this->synchronizeTaskARun();
        $this->synchronizeTaskBRun();
        $this->synchronizeTaskCRun();

        // Finish all tasks and show test results
        Performance::results();
    }

    public function synchronizeTaskARun()
    {
        // Set point Task A
        Performance::point(__FUNCTION__);

        //
        // Run code
        sleep(1);
        //

        // Finish point Task A
        Performance::finish();
    }

    public function synchronizeTaskBRun()
    {
        // Set point Task B
        Performance::point(__FUNCTION__);

        //
        // Run code
        sleep(1);
        //

        // Finish point Task B
        Performance::finish();
    }

    public function synchronizeTaskCRun()
    {
        // Set point Task C
        Performance::point(__FUNCTION__);

        //
        // Run code
        sleep(1);
        //

        // Finish point Task C
        Performance::finish();
    }
}