My model is gradually slower down to an unacceptable speed(i.e. from 200 ticks per second to several seconds for one tick). I'd like to understand what the causes to this problem. What is a simplest way to check which part of the model is increasingly consuming the time? I tried used some other java profiler before but it's not good and difficault to understand.
Asked
Active
Viewed 34 times
1 Answers
2
A Java profiler like YourKit is the best way approach since it will provide the code "hots pots" in terms of the execution times for each class method. Alternatively, you can insert a few timing functions in parts of your model that you suspect contribute to most of the execution time, for example:
long start = System.nanoTime();
// some model code here
long end= System.nanoTime();
System.println("Step A time in seconds: " + (end - start)/1E9);

Eric Tatara
- 715
- 3
- 12
-
Thanks I used this method before. the problem is it count the time for every single agent execution, which is small. but together it's big (like 500000 agents). is there tools that can help to collect the total time of a method performed by all agents (at agent set level)? – Jack Jul 06 '20 at 20:29
-
When I've seen this in my own work, its typically because some collection I'm looping over is getting larger at some increasing rate (e.g. each agent in list adds another agent to that list kind of thing). Might be worth checking that. In the end though a profiler is a great way to figure this sort of thing out. – Nick Collier Jul 07 '20 at 13:41