Setting VisualVM Up

Jump to navigation Jump to search

Setting VisualVM Up

Does anyone have any experience getting this to work in order to profile a robot? I can get it to profile robocode but as soon as I try to profile my robot I get all sorts of errors in my robot's log output followed by it being "banned" by robocode.

Or are people using something else to do profiling? If so, what and how?

Thanks!

Wolfman (talk)20:33, 5 November 2017

I do it with a special profiler class in my EvBotNG which is the part of my framelib. You can see the profiler class at profiler.java. The examples of it use are sprinkled all over EvBotNG. In the essence, when you need to start a timer for some code you say profiler.start( "methodName" ) and then at the end of the profiled code you say profiler.stop( "methodName" ). Once you ready to see the stats, you call profiler.formatAll( ). I do it at the end of every round.

This will print a nice looking statistic table which shows nested profiled chunks in a tree like structure. Something like

Profiler stats---------------------------
  times exec |      min |  average |      max |    total | method name
           9 |   3.1 mS |   3.6 mS |   5.9 mS |  32.0 mS | gameInfo.initBattle
       10430 |   1.2 mS |   3.0 mS |  22.7 mS |  31.0  S | gameInfo.ticCycle
       10430 | 108.8 uS | 842.2 uS |  17.9 mS |   8.8  S |   gameInfo.initTic
       10430 |   506 nS |   2.2 uS | 103.1 uS |  22.4 mS |     botsManager.initTic
       10430 |  96.1 uS | 586.0 uS |  17.7 mS |   6.1  S |     fighterBot.initTic eem.EvBotNG vtest
       10430 |   540 nS |   2.5 uS | 264.8 uS |  25.7 mS |       gunManager.initTic
       10430 |  89.1 uS | 570.1 uS |  17.7 mS |   5.9  S |       motion_exactPathDangerMotion.initTic
        9627 |  82.1 uS | 390.8 uS |  14.7 mS |   3.8  S |         choseNewPath with nTrials = 2
         803 | 605.2 uS |   2.4 mS |  17.7 mS |   2.0  S |         choseNewPath with nTrials = 20
       10430 |   383 nS |   1.4 uS |  52.5 uS |  14.2 mS |       processScheduledEnergyDrop
         200 |   3.5 uS | 144.0 uS |   3.5 mS |  28.8 mS |       removeBulletsOutsideOfHitRegion
       10172 |   2.7 uS | 106.5 uS |  10.4 mS |   1.1  S |     fighterBot.initTic jk.mega.DrussGT 3.2.1
       10172 |   458 nS |   1.6 uS |  80.4 uS |  16.1 mS |       gunManager.initTic
       10172 |   387 nS | 100.1 uS |  10.3 mS |   1.0  S |       processScheduledEnergyDrop
        2484 |  12.3 uS |  46.0 uS |   1.3 mS | 114.3 mS |         calcFiringSolutionGFdangers
       10430 |   4.5 uS | 126.7 uS |  12.8 mS |   1.3  S |     wavesManager.initTic
       10430 |  14.2 uS |   2.1 mS |  19.5 mS |  22.2  S |   gameInfo.run
        6655 | 130.3 uS |   1.1 mS |  16.5 mS |   7.4  S |     Thread.sleep
       10430 |   5.6 uS |   1.4 mS |  19.4 mS |  14.7  S |     fighterBot.manage eem.EvBotNG vtest
       10430 |   3.9 uS |   1.4 mS |  19.4 mS |  14.5  S |       gunManagerManage
        2369 |  14.5 uS |  55.3 uS |   4.8 mS | 131.1 mS |         calcFiringSolutionGFdangers
       10430 |   634 nS |  18.7 uS | 558.3 uS | 195.0 mS |         gunManagerManage.aimTheGun
       10430 |   574 nS |   1.3 mS |  19.4 mS |  13.9  S |         gunManagerManage.findTheBestTarget
       10172 |   440 nS |   2.0 uS |   1.1 mS |  20.4 mS |     fighterBot.manage jk.mega.DrussGT 3.2.1
---------------------------
Beaming (talk)03:58, 6 November 2017
 

At least on the time performance side, I basically do the same thing most of the robocoders do: logging logs to the console. On the memory side, though, it is a nice question. :)

Rsalesc (talk)04:26, 6 November 2017
 

Well, you can try to disable security check of robocode. -Ddebug iirc

Xor (talk)16:59, 6 November 2017