CodeIgniter Forums
how can i get {elapsed_time} variable in controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Learn More (https://forum.codeigniter.com/forumdisplay.php?fid=15)
+--- Thread: how can i get {elapsed_time} variable in controller (/showthread.php?tid=62061)



how can i get {elapsed_time} variable in controller - ngangchill - 06-05-2015

i have used philo/laravel-blade as template engine. i cant find any idea how to show {elapsed_time} in view file that is parsed by philo/laravel-blade ...


some one help me.


RE: how can i get {elapsed_time} variable in controller - mwhitney - 06-05-2015

I believe that, even if you use $this->benchmark->elapsed_time(), it's just going to output '{elapsed_time}', because the total execution time isn't available until the Output class makes the substitution.

If you're still going through the Output class, you just need to find a way to escape the output in your template engine to maintain the curly braces in the {elapsed_time} pseudo-variable.

If you're bypassing or overriding the Output->display() method, you would need to use (more or less) the same code which is used in that method to get the information you're looking for. If you do this, though, remember that the {elapsed_time} is not accurate unless the benchmark->elapsed_time() method is called as close as possible to the end of the server's response (right before output actually begins).


RE: how can i get {elapsed_time} variable in controller - ngangchill - 06-05-2015

(06-05-2015, 11:59 AM)mwhitney Wrote: I believe that, even if you use $this->benchmark->elapsed_time(), it's just going to output '{elapsed_time}', because the total execution time isn't available until the Output class makes the substitution.

If you're still going through the Output class, you just need to find a way to escape the output in your template engine to maintain the curly braces in the {elapsed_time} pseudo-variable.

If you're bypassing or overriding the Output->display() method, you would need to use (more or less) the same code which is used in that method to get the information you're looking for. If you do this, though, remember that the {elapsed_time} is not accurate unless the benchmark->elapsed_time() method is called as close as possible to the end of the server's response (right before output actually begins).

if i use $this->benchmark->elapsed_time() in template it prints {elapsed_time} that is pseudovariable.




/**
     * Render page 
     *
     * @param  string       $file 
     * @param  array        $arguments 
     * @return null
     */
    public function make($file = false)
    {
if($file) {
echo $this->engine->view()->make($file, ci()->data);
} else {
$controller = ci()->router->fetch_class();
$method = ci()->router->fetch_method(); 
echo $this->engine->view()->make($controller.'.'.$method, ci()->data);
}
    }


RE: how can i get {elapsed_time} variable in controller - InsiteFX - 06-06-2015

See the CodeIgniter Users Guide:

Benchmarking Class