Because
codeigniter.ttim.ru is unavailable,
I post the parts of the framework documentation that I translated here.
Performance test class
')
This class allows you to calculate the difference in execution time between two marked points in time.
It starts automatically when the framework is called and ends right before sending the view to the browser.
Class use
The Benchmark class can be used inside controllers, views and models. The process of use is as follows:
- Mark the starting point.
- Then mark the final.
- Call the
elapsed_time()
function to display the result.
Code example:
this->benchmark->mark('code_start');
// ,
$this->benchmark->mark('code_end');
//
echo $this->benchmark->elapsed_time('code_start', 'code_end');
Benchmark and Profiler Classes
Profiler class description (eng.)In order for the Benchmark data to be available for Profiler, all labels must be paired, and their names must be
end with
_start and
_end . The first part of the name of the paired tags must match.
Example:
$this->benchmark->mark('my_mark_start');
//
$this->benchmark->mark('my_mark_end');
$this->benchmark->mark('another_mark_start');
//
$this->benchmark->mark('another_mark_end');
Output full time
If you want to display the full time from the start of CodeIgniter work and ending with the output of information in the browser,
Add the following line to the template:
<?=$this->benchmark->elapsed_time();?>
In the case of using the template engine :.
{elapsed_time}
Memory consumption
.
If PHP is installed with the --enable-memory-limit option, you can output the amount of memory consumed by the system:
<?=$this->benchmark->memory_usage();?>
So or
{memory_usage}
Attention, this function can be used only in species files.