I recently discovered jvisualvm and have been using it to profile mkgmap. One thing I haven't discovered yet is how to profile an application from the start - its trivial to attach to an already running java app using the gui but if it's already running, you could miss some useful info. So, the attached patch is a little kludge that lets you start mkgmap but then it immediately pauses for a little while (long enough to attach jvisualvm to it and turn on the profiling, etc.) before it gets down to work.
To use this, just add -Dsleep-on-startup=30 or similar to your Java args. Can anyone think of a better way of achieving the same goal? Mark
diff --git a/src/uk/me/parabola/mkgmap/main/Main.java b/src/uk/me/parabola/mkgmap/main/Main.java index 8e9a389..a304c46 100644 --- a/src/uk/me/parabola/mkgmap/main/Main.java +++ b/src/uk/me/parabola/mkgmap/main/Main.java @@ -88,6 +88,18 @@ public class Main implements ArgumentProcessor { */ public static void main(String[] args) { + try { + int delayPeriod = Integer.decode(System.getProperty("sleep-on-startup", "0")); + if(delayPeriod > 0) { + System.err.println("Sleeping for " + delayPeriod + " seconds..."); + Thread.sleep(delayPeriod * 1000); + System.err.println("Wake up, time for work!"); + } + } + catch(Exception e) { + // relax + } + // Temporary test for version 1.6. During a transition period we are // compiling with target 1.5 so that it will run with 1.5 long enough // to give an error message.
_______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev