MyMomSaysIamSpecial MyMomSaysIamSpecial - 10 months ago 135
Smarty Question

CodeIgniter benchmarking with Smarty

I've connected Smarty to CodeIgniter and now of course i cant use {memory_used} and {elapsed_time}, but i want to know how i can output this information to my webpage now?

Answer Source

Benchmark class

$this->benchmark->elapsed_time()
$this->benchmark->memory_usage()

They do return their mustached values that are parsed by output class later, so if you use Smarty, you can basically use the raw functions CodeIgniter uses itself.

$memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB';
global $BM; // needed only for elapsed_time
$elapsed_time = $BM->elapsed_time('total_execution_time_start', 'total_execution_time_end');

Note it is really a workaround and there should be better ways to do it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download