Getting solver time for CVX with Gurobi

Hello Experts,

I am using Gurobi solver with CVX. I want to find the solver time taken to solve my problem.
How can I get it?

I think it is not possible to get the pure time gurobi spends on solving the problem.
The closest indication on how long it takes to solve any problem in cvx can be acquired as follows:

  1. Place a code line to initiate measuring time just before cvx_begin;

  2. Measure the elapsed time just before cvx_end (the time to formulate the problem);

  3. Measure the elapsed time just after cvx_end (the time to formulate and solve the problem);

  4. The time to solve the problem can be found by subtracting elapsed times found in steps 3 and 2.

In code format:

tstart = tic;
t1 = toc(tstart);
t2 = toc(tstart);
time_to_solve = t2 - t1;
1 Like