问题
Could anyone explain {elapsed_time} & {memory_usage} pseudo-variables in CodeIgniter? What template is this referring to?
In Benchmark.php
/**
* Memory Usage
*
* This function returns the {memory_usage} pseudo-variable.
* This permits it to be put it anywhere in a template
* without the memory being calculated until the end.
* The output class will swap the real value for this variable.
*
* @access public
* @return string
*/
function memory_usage()
{
return '{memory_usage}';
}
Thanks
回答1:
Those variables are from the Benchmarking class.
Quote from the official doc :
{elapsed_time}
display the total elapsed time from the moment CodeIgniter starts to the moment the final output is sent to the browser
{memory_usage}
The consumption will reflect the total memory used by the entire app
See how it works here : http://www.codeigniter.com/user_guide/libraries/benchmark.html
One use of this class is checking blocks of code :
public function myfunction()
{
//Stuff here
$this->benchmark->mark('start');
//Stuff suspected to be slow
$this->benchmark->mark('end');
echo $this->benchmark->elapsed_time('start', 'end');
}
来源:https://stackoverflow.com/questions/28649101/elapsed-time-memory-usage-pseudo-variable-in-codeigniter