# Comparing computational times across solvers (Gurobi, IPOPT, Knitro) in AMPL

**URL:** <https://discuss.ampl.com/t/comparing-computational-times-across-solvers-gurobi-ipopt-knitro-in-ampl/2187>\
**Category:** Support\
**Tags:** solvers, displays-results\
**Created:** [August 1, 2025, 2:54pm UTC](https://discuss.ampl.com/t/comparing-computational-times-across-solvers-gurobi-ipopt-knitro-in-ampl/2187 "2025-08-01T14:54:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![salvapinedam](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/salvapinedam/32/900_2.png) [@salvapinedam](https://discuss.ampl.com/u/salvapinedam)\
**Post date:** [August 1, 2025, 2:54pm UTC](https://discuss.ampl.com/t/comparing-computational-times-across-solvers-gurobi-ipopt-knitro-in-ampl/2187/1 "2025-08-01T14:54:02Z")

</div>

Hi all,

We are running a set of experiments using AMPL with different solvers: Gurobi, IPOPT, and Knitro. Our goal is to benchmark their performance on a common problem. However, we are running into difficulties when trying to compare computational times in a consistent and meaningful way.

It seems that the times reported back to AMPL (via solve\_result or solve\_message) differ not only in format but also in what they actually represent. For instance:

Gurobi exposes “Work” units, which are deterministic and repeatable, but we don’t see a way to access this from AMPL.

IPOPT and Knitro report CPU times, but they vary from run to run, even with the same input and settings.

solve\_result\_num sometimes gives inconsistent or implementation-specific values depending on the solver.

Does anyone have advice or best practices on how to compare solver times in AMPL?  
Is there a reliable way to extract solver CPU time or wall time for different solvers in a uniform way from AMPL?

Any help or suggestions would be greatly appreciated.

Thanks!  
Salvador

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [August 5, 2025, 5:38pm UTC](https://discuss.ampl.com/t/comparing-computational-times-across-solvers-gurobi-ipopt-knitro-in-ampl/2187/2 "2025-08-05T17:38:19Z")

</div>

There are two solver time values available from AMPL, in the following built-in parameters:

- `solve_time` reports the CPU time
- `solve_elapsed_time` reports the wall-clock time

These do not include any time spent in the AMPL process, but only time spent in the (separate) solver process. You can show them with a `display` or `print` statement after the solver has finished.

When evaluating solvers that may run multiple threads in parallel — for example, Gurobi and Knitro — `solve_time` does not reflect the effectiveness of the parallelization, because it is the sum of CPU times on all the individual threads. Thus you should rely on `solve_elapsed_time`, which will of course be most reliable if you can use a computer that does not have any other time-consuming processes running at the same time.

The Gurobi work units are only useful for comparing different Gurobi options. Gurobi’s [Performance](https://support.gurobi.com/hc/en-us/sections/360009927972-Performance) page has links to some interesting discussions of how to make performance comparisons, and some parts of those discussions are even useful for comparing other solvers.

---

<div class="post-metadata">

**Author:** ![salvapinedam](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/salvapinedam/32/900_2.png) [@salvapinedam](https://discuss.ampl.com/u/salvapinedam)\
**Post date:** [September 9, 2025, 2:54pm UTC](https://discuss.ampl.com/t/comparing-computational-times-across-solvers-gurobi-ipopt-knitro-in-ampl/2187/3 "2025-09-09T14:54:36Z")

</div>

Thanks for the response. The thing is that both solve\_time and solve\_elapsed\_time vary if the experiment is repeated several times, while the WorkTime reported by Gurobi is deterministic. Any easy way to access that output provided by Gurobi using AMPL?

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [September 9, 2025, 6:15pm UTC](https://discuss.ampl.com/t/comparing-computational-times-across-solvers-gurobi-ipopt-knitro-in-ampl/2187/4 "2025-09-09T18:15:32Z")

</div>

Here’s the Gurobi option from [https://dev.ampl.com/solvers/gurobi/options.html](https://dev.ampl.com/solvers/gurobi/options.html) for requesting access to the work time:

```auto
tech:reportwork (reportwork, work)
      0*/1: Whether to report the work spent in the optimization in the
      problem suffix `work`. Gurobi's work units are deterministic, and
      roughly equivalent to one second on a single thread.

```

So for example if you add`tech:reportwork=1`to your`gurobi_options`string, you can retrieve work units in`Initial.work.`(The suffix .work tells you the work total for the last solve of the current problem. When you’re not using AMPL’s named problem feature, the current problem is always`Initial`.)

This measure of work is specific to Gurobi, so it won’t help you with comparisons to other solvers.
