{elapsed_time} & {memory_usage} CodeIgniter 中的伪变量

{elapsed_time} & {memory_usage} pseudo-variable in CodeIgniter

谁能解释一下 CodeIgniter 中的 {elapsed_time} 和 {memory_usage} 伪变量?这是指什么模板?

在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}';
}

谢谢

这些变量来自基准测试class。

引自官方文档:

{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

在这里查看它是如何工作的:http://www.codeigniter.com/user_guide/libraries/benchmark.html

此 class 的一个用途是检查代码块:

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');
}