CPU Time vs. Elapsed Time in AMPL

1,820 views
Skip to first unread message

Vahid Nourbakhsh

unread,
Oct 8, 2014, 11:25:06 AM10/8/14
to am...@googlegroups.com

Hi,

Could you explain the difference between these times?

_ampl_time  vs. _ampl_elapsed_time   OR

_total_solve_elapsed_time vs. _total_solve_time

 

Here is my understanding.

Say you watch a movie on your computer while you run AMPL+CPLEX.  If the movie takes 50% of the CPU, then the Elapsed Time for the AMPL job will get longer. But the CPU time will stay the same.  The CPU time is the amount of time it would take to run the job if 100% of the CPU was running the AMPL job.  That’s my interpretation of it.  Note that since one CPU has multiple cores, and certain tasks can only run in one core, then it sometimes happens that CPU time is much less than Elapsed time even when no other CPU-intensive programs are running. This is because (and I think this is the case) the CPU time is computed assuming a single core.

 

Thanks,

Vahid

 

 

 

fbahr

unread,
Oct 8, 2014, 3:51:37 PM10/8/14
to am...@googlegroups.com
_ampl_elapsed_time := elapsed seconds since the start of the AMPL process
_ampl_system_time  := system CPU seconds used by the AMPL process itself
_ampl_time         := _ampl_system_time + _ampl_user_time

_total_solve_elapsed_time := elapsed seconds used by all solve commands
_total_solve_user_time    := user CPU seconds used by all solve commands
_total_solve_time
         := _total_solve_system_time + _total_solve_user_time


--fbahr (via [1])

[1]: http://tomopt.com/ampl/service/displays.php

Robert Fourer

unread,
Oct 8, 2014, 4:05:58 PM10/8/14
to am...@googlegroups.com
You are right that that "elapsed" timings are the so-called wall clock times, which will be longer if your computer is more heavily loaded. However the non-"elapsed" times are the total CPU time for all threads. So if you are running one thread, the total CPU time will be more stable than the elapsed time. But if you are running multiple threads then the total CPU time will in general be higher than elapsed time, since it will equal sum {i in THREADS} time[i] where time[i] is the CPU time in the ith thread. (Note that many recent computers are hyperthreaded so that there can be twice as many threads as cores.)

For timing multi-threaded applications the usual recommendation is to run with the computer empty and compare elapsed timings, since the whole point of multi-threading is to reduce the overall elapsed time by doing work in parallel.

Bob Fourer
am...@googlegroups.com

=======

Vahid Nourbakhsh

unread,
Nov 22, 2015, 2:51:52 AM11/22/15
to AMPL Modeling Language, 4...@ampl.com
Thank you Bob,

Vahid
Reply all
Reply to author
Forward
0 new messages