Measure Execution Time

There are situations where you would like to know the duration of execution of an AIMMS code-block. In AIMMS Developer, you can do this easily by using the built-in Profiler, accessed through Tools -> Diagnostic Tools -> Profiler. This profiler will provide you with information about how long each statement in an execution took, as well as how long the evaluation of the definition of a parameter took. More information about the profiler can be found in The AIMMS profiler.

You can also start the profiler using the function ProfilerStart(). It is common to make a call to this function in the initialization procedures so that you can always have the profiler available while developing an AIMMS application.

In addition, you can query the profiler using the procedure ProfilerCollectAllData().

See all related functions in AIMMS Function Reference - Development Support

Using the AIMMS Profiler has two rather minor disadvantages for measuring execution time:

  1. The AIMMS Profiler cannot be active when the AIMMS Debugger is active.

  2. The AIMMS Profiler does not support directly the measuring of a code fragment, or the measuring of a piece of code executed when some condition is true.

When fine control of measured execution time is needed, the time functions of AIMMS can be used. To illustrate, and ease the use, an AIMMs 4.87 Example project and can be downloaded.

Example project

Download the example AIMMS Project

MainExecution in this procedure shows the usage of the procedures built in the stopwatchLibrary library.

1! Measuring time of some long running procedure.
2stopwatch::pr_start() ;
3pr_LongRunningProcedure  ;
4p_elapsedTime := stopwatch::fnc_elapsed();
6! Reporting of that time, whereever.
7sp_runTime := formatString("Execution of procedure took %n seconds", p_elapsedTime );
8! DialogMessage(sp_runTime);

In this procedure, we use functions from the stopwatchLibrary to measure the time it took to execute pr_LongRunningProcedure. Line-6 is simply constructing a message using the stopwatch results.

stopwatch Library

Please Stopwatch Library with prefix stopwatch and add it to your project. This library exposes a procedure and a function:

  1. pr_start() Mark “now” as a starting point for measuring wall clock execution time.

  2. fnc_elapsed Return the wall clock time elapsed in seconds since the last call to pr_start()


  • In 2011, Guido Diepen developed the first Stopwatch section and blogged about it.

  • In 2022, Chris Kuip made a small library out of that section, to

    • ease even further the adding of the functionality to an application, and

    • to cater for multi timezone support, see option Use_UTC_forcaseandstartenddate