How to get the runtime or CPU time?

Asked by Danny (Dingeman) van der Haven

Hi all!

I would like to time the running time of the simulation at various stages. With this I mean the CPU time or the actual real-world time it take to run the simulation.

I have tried the instructions at
But I just get a message that yade.timing does not have the attribute 'timing', even after setting O.timingEnabled=True.
I really just want to use yade.timing.runtime() and write its output to a file.
I don't need a very precise timing or to know how long the engine takes. I just need the current CPU time.

Does YADE have this option or do I need to resort to general Python functions?

With kind regards,

Question information

English Edit question
Yade Edit question
No assignee Edit question
Solved by:
Danny (Dingeman) van der Haven
Last query:
Last reply:
Revision history for this message
Karol Brzezinski (kbrzezinski) said :

Hi Danny,

It may be a little bit of a workaround, but every periodic engine (e.g. PyRunner) stores the information about the time of the last run. You could use it to track the time of the simulation. For example, if the last engine in the list is PyRunner, you can check:


Revision history for this message
Jérôme Duriez (jduriez) said :


There should be no problem in using timing module (have you "from yade import timing" first ?). Using time.time Python functions is still not a bad idea though as the timing module induces some overhead (see the doc).


Revision history for this message
Bruno Chareyre (bruno-chareyre) said :

Python's time.time() is enough in many cases, as long as you don't need per-engine data or nano-second accuracy.

t1 = time.time()
realTime = time.time() - t1

yade.timing is convenient if you want more granularity in the timings (you probably forgot 'from yade import timing'). You can also introduce your own checkpoints in the source code which will be reflected in the output of yade.timing.stats().


Revision history for this message
Danny (Dingeman) van der Haven (dlhvdh) said :

Thank you all! Those suggestions indeed sovled my problem.