Idea time API Codeigniter REST

I am using codeigniter REST-API (by philsturgeon Ref URL:

https://github.com/philsturgeon/codeigniter-restserver )

I want to add to the answer how long it took for the service to generate and process the response.

I am trying to use $this->benchmark->elapsed_time()

in my controller but it doesnโ€™t send time, it sends

"success": 1,"took": "{elapsed_time}",

      

I tried to edit the main controller api abstract class REST_Controller extends CI_Controller

and add the elapsed time to the final output postpublic function response($data = null, $http_code = null, $continue = false)

But no luck I keep getting "{elapsed_time}"

Any help would be really appreciated.

+3


source to share


1 answer


You can get elapsed_time

using this



$this->benchmark->mark('code_start');

// Some code happens here

$this->benchmark->mark('code_end');

echo $this->benchmark->elapsed_time('code_start', 'code_end');

      

+2


source







All Articles