FAQ: is the bottleneck of my optimization in CasADi function evaluations or in the solver? - casadi/casadi GitHub Wiki
You should interpret the output you get when running an nlp/conic with 'print_time' true option enabled (default).
Sample of an output:
Total CPU secs in IPOPT (w/o function evaluations) = 0.012
Total CPU secs in NLP function evaluations = 0.075
EXIT: Optimal Solution Found.
solver : t_proc (avg) t_wall (avg) n_eval
nlp_f | 1.28ms ( 49.23us) 1.28ms ( 49.20us) 26
nlp_grad_f | 3.86ms (143.07us) 3.87ms (143.23us) 27
nlp_hess_l | 69.93ms ( 2.80ms) 69.97ms ( 2.80ms) 25
total | 88.01ms ( 88.01ms) 88.01ms ( 88.01ms) 1
This timing does not include the overhead of transferring your problem from Python/Matlab to CasADi compiled libraries, or upfront memory allocations associated with the standard CasADi Function call API.
t_wall versus t_proc
What you most likely care about is the 'wall' time, i.e. the time that elapsed on a clock on the wall while your script was running, as opposed to 'proc' time which sums the total time spent across all cpus involved in making computations for your script. They typically differ when you parallelize. On Windows, 'proc' and 'wall' time are reported the same, incorrectly. The timing that Ipopt itself shows corresponds to 'proc'.
Where is my bottleneck?
The nlp_* parts are helper CasADi Functions that were created by CasADi to answer questions that the solver might ask.
In this case, the solver asked 26 times for the value of the objective, 27 times for a gradient of the objective, and 25 times for the Hessian of the Lagrangian. The total amount of time spent in these Function evaluations was 1.28+3.87+69.97 ms = 75.12 ms.
The time spent in Ipopt is 88.01 - 75.12 ms = 12.35 ms.
As a consequence, the bottleneck is in CasADi, and options expand and/or jit might be appropriate for speeding up, or using parallel map