You never can tell

In my first experiences of making an ABM, I’ve been surprised by how slowly a seemingly simple Java program can run. This led me to look at how to profile a running Java application to see where it’s spending most of its time.

Oracle’s frankly-amazing Java VisualVM allows you to do just that and the results, in my case, were highly unexpected.

Despite running an ABM with, as I thought, fairly high levels of structural complexity (i.e. agents all have their own worldview, including little imaginary copies of all the other agents they know about, which get updated as and when an indenpendent and omniscient ‘GamesMaster’ allows), the program turned out to be spending the vast, vast majority of its time working out which spaces are neighbours to which others. This is clearly absurd and now I’m off to tweak the algorithm. A faster model should result…

First ever profiler output
Profiler output showing huge overheads in checking neighbouring spaces

Author: Rob Levy

Economist at NEF. Former teaching Fellow in Economics at UCL and Bristol University. Recently submitted my PhD. We'll see what happens...

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: