Which is best practice to add data processing on controller or .ctp section

Which is best practice to add data processing on controller or .ctp section.

I know the MVC model but Some function need more time execute. How can Minimize the execution time.

It depends on the task.
If its some database query, analyze the query and add indexes or use cache.

If it is a real process (like a long loop) then you should do it on a Command, and run that command separate from any request, the command should update every X minutes the % progress.
In a controller/view, you only show the % done, and show the results when complete.

You can launch the command from a request (if your host allows it), or you can run the command in a cronjob, using some form of a queue (see Queue List in Awesome CakePHP)

ok, Thanks, I can try your suggestion. I have long loop