Benchmark Library



( ZN >= 0.0.1 )

The Benchmark library was created to test the performance of your system or code.

 

# Methods


void start ( String $ test )
void end ( String $ test )
this run ( Callable $ callback )
float elapsedTime ( String $ result , Int $ decimal = 4 )
Int memoryusage ( Boolean $ realmemory = false )
Int maxmemoryusag to ( Boolean $ realmemory = false )
Int calculatedMemory ( String $ result )
Array usedFiles ( String $ result = NULL )
Int usedFileCount ( String $ result = NULL )

 

# Start ( ZN >= 0.0.1 )


Starts the test.

Parameters

String $ test Test name.
return void

Use of

Benchmark::start('test');
# your codes
Benchmark::end('test');

 

# End ( ZN >= 0.0.1 )


End the test.

Parameters

String $ test Test name.
return void

Use of

Benchmark::start('test');
     # your codes
Benchmark::end('test');

Benchmark::start('test1');
     # your codes
Benchmark::end('test1');

 

# Run ( ZN> = 4.0.1 )


It does the operation that Benchmark :: start () and Benchmark :: end () do.

Parameters

callable $ CallBack Codes to measure performance.
return this

Optional Methods

this result ()

Use of

File: Controller / TestController.php
<?php namespace Project\Controllers;

use Benchmark, DB;

class TestController extends Controller
{
    public function main(String $params = NULL)
    {
        $bench = Benchmark::run(function()
        {
            DB::get('users')->result();
        });

        output($bench->result());
    }
}
elapsedTime => double 0.0162 (length = 6 )
calculatedmemory => double 407,640 (length = 6 )
usedfilecount => integer 18 (length = 2 )
usedfiles => object
(
        129 => string "Internal / Libraries / Database / dbınternaldb.php ' (length = 107 )
        130 => string 'Internal / Libraries / Database / DBInternalDB.php' (length = 72 )
        131 => string "Internal / Libraries / Database / Connection.php ' (length = 69 )
        132 => string " Internal / Libraries / Database / connectionınterface.php' (length = 78 )
        133 => string "Internal / Libraries / Database /Database/DBTraitsVariableTypesTrait.php ' (length = 87 )
        134 => string ' Internal / Libraries / Database / Database / DBTraitsStatementsTrait.php ' (length = 84 )
        135 => string 'Internal / Libraries / Database / dbtraitsfunctionstrait.php' (length = 83 )
        136 => string "Internal / Libraries / Database / dbınternaldbınterface.php ' (length = 81 )
        137 => string ' Projects / example / config / Database.php ' (length = 63 )
        138 => string ' Internal / Libraries / IndividualStructures / Support ' (length = 129 )
        139 => string ' Projects / Example / Resources / Statics / Internal / Libraries / Individual / Structures / Support / InternalSupport.php ' / ınternalsupport.php ' (Length = 94 )
        140 => string "Internal / Libraries / Requirements / Controllers / callcontroller.php ' (length = 89 )
        141 => string " Internal / Libraries / ındividualstructures / support / ınternalsupportınterface.php' (length = 103 )
        142 => string "Internal / Libraries / Database / driverspdopdo.php ' (length = 74 )
        143 => string " Internal / Libraries / Database / driverconnectionmappingabstract.php' (length = 90 )
        144 => String "Internal / Libraries / Database / Properties.php ' (length = 69 )
        145 => string " Internal / Libraries / Database / driverspdodriversmysql.php' (length = 84 )
        146 => string "Internal / Libraries / Database / DriversPDODriverInterface.php ' (length = 86 )

 

# ElapsedTime ( ZN >= 0.0.1 )


It is used to find out the elapsed time after the test.

Parameters

String $ test Test name.
Int $ decimal = 4 The number of decimal digits.
return float

uses

\Output::writeLine( Benchmark::elapsedTime('test', 5) );
\Output::writeLine( Benchmark::elapsedTime('test1', 6) );
0.87320
0.429302

 

# MemoryUsage ( ZN >= 0.0.1 )


It is used to find out how many bytes the PHP code occupies in the system.

Parameters

Bool $ realMemory = false Do you calculate the actual memory amount?
return float

uses

echo Converter::byte( Benchmark::memoryUsage() );
876.9 KB

 

# MaxMemoryUsage ( ZN >= 0.0.1 )


It is used to find out the maximum amount of memory allocated to PHP codes.

Parameters

Bool $ realMemory = false Do you calculate the actual memory amount?
return float

uses

echo Converter::byte( Benchmark::maxMemoryUsage() );
1 MB

 

# CalculatedMemory ( ZN >= 2.0.0 )


It is used to calculate how much space a PHP code takes up in memory.

Parameters

String $ test Test name.
return float

uses

echo Benchmark::calculatedMemory('test'); 
echo Benchmark::calculatedMemory('test1');
13882
12231
Warning : The calculations of this method may not give 100% correct results .

 

# UsedFiles ( ZN >= 2.0.0 )


Outputs the list of files used in the test in the array type.

Parameters

String $ test Test name.
return Array

uses

output( Benchmark::usedFiles('test1') );

 

# UsedFileCount ( ZN >= 2.0.0 )


Outputs the number of files used in the test.

Parameters

String $ test Test name.
return Int

uses

echo Benchmark::usedFileCount('test1');
10