profiling

Dear JGO Members,

I’ve read the guide in the java2D section about profiling, I’ve tried passing the variables as argument in Eclipse but still can’t get it to work. Sorry that I’m pretty new to profiling it would be really nice if someone can shade me some light on how profiling works. Thanks in advance!

Edit: After abit more search I found out -Xpro can do profiling, did it on CMD, but I’m not sure exactly what those mean, like what’s good it terms of performance and whats bad?



C:\>java -jar -Xprof GGt.jar

Flat profile of 34.68 secs (3128 total ticks): AWT-Windows

  Interpreted + native   Method
 99.7%     0  +  3119    sun.awt.windows.WToolkit.eventLoop
  0.1%     2  +     0    sun.awt.AWTAutoShutdown.setToolkitBusy
  0.0%     1  +     0    sun.reflect.NativeMethodAccessorImpl.invoke
  0.0%     1  +     0    sun.awt.SunToolkit.wakeupEventQueue
  0.0%     0  +     1    java.lang.Object.hashCode
  0.0%     0  +     1    sun.awt.windows.WToolkit.init
 99.9%     4  +  3121    Total interpreted

     Compiled + native   Method
  0.1%     0  +     3    sun.awt.AWTAutoShutdown.setToolkitBusy
  0.1%     0  +     3    Total compiled


Flat profile of 0.11 secs (7 total ticks): Thread-1

  Interpreted + native   Method
100.0%     0  +     7    sun.awt.windows.WToolkit.shutdown
100.0%     0  +     7    Total interpreted


Flat profile of 34.70 secs (3127 total ticks): AWT-EventQueue-0

  Interpreted + native   Method
 31.0%     0  +    26    sun.awt.windows.WFramePeer.setState
 23.8%     0  +    20    sun.awt.windows.WGlobalCursorManager.setCursor
 13.1%     0  +    11    sun.awt.windows.WGlobalCursorManager.findHeavyweightUnd
erCursor
  9.5%     0  +     8    sun.awt.windows.WComponentPeer.nativeHandleEvent
  8.3%     1  +     6    sun.awt.Win32GraphicsDevice.enumDisplayModes
  1.2%     0  +     1    java.lang.Thread.holdsLock
  1.2%     0  +     1    java.lang.Object.clone
  1.2%     0  +     1    java.lang.Class.getInterfaces
  1.2%     0  +     1    sun.awt.windows.WComponentPeer.reshape
  1.2%     0  +     1    sun.java2d.loops.FillRect.FillRect
  1.2%     0  +     1    sun.java2d.windows.GDIBlitLoops.nativeBlit
  1.2%     1  +     0    java.awt.DisplayMode.<init>
  1.2%     1  +     0    sun.awt.AWTAutoShutdown.notifyThreadBusy
  1.2%     1  +     0    java.awt.Window.processWindowEvent
  1.2%     1  +     0    java.awt.EventQueue.setCurrentEventAndMostRecentTimeImp
l
 97.6%     5  +    77    Total interpreted

     Compiled + native   Method
  1.2%     1  +     0    sun.awt.AppContext.get
  1.2%     1  +     0    Total compiled

         Stub + native   Method
  1.2%     0  +     1    java.lang.Thread.currentThread
  1.2%     0  +     1    Total stub

  Thread-local ticks:
 97.3%  3043             Blocked (of total)


Flat profile of 34.78 secs (3134 total ticks): AWT-Shutdown

  Thread-local ticks:
100.0%  3134             Blocked (of total)


Flat profile of 34.80 secs (3136 total ticks): Java2D Disposer

  Thread-local ticks:
100.0%  3136             Blocked (of total)


Flat profile of 34.88 secs (3142 total ticks): main

  Interpreted + native   Method
  2.9%     0  +    92    sun.nio.ch.FileDispatcher.read0
  1.9%     0  +    61    sun.java2d.windows.GDIBlitLoops.nativeBlit
  1.1%     0  +    36    sun.java2d.loops.Blit.Blit
  0.4%     0  +    14    sun.java2d.loops.FillRect.FillRect
  0.4%     0  +    13    java.io.RandomAccessFile.close0
  0.2%     0  +     5    java.io.RandomAccessFile.open
  0.2%     5  +     0    java.awt.image.DataBufferByte.<init>
  0.2%     0  +     5    java.util.zip.Inflater.inflateBytes
  0.1%     0  +     4    sun.font.FontManager.populateFontFileNameMap
  0.1%     0  +     3    sun.font.FileFont.getGlyphImage
  0.1%     3  +     0    java.lang.AbstractStringBuilder.<init>
  0.1%     0  +     3    sun.java2d.loops.DrawGlyphList.DrawGlyphList
  0.1%     0  +     2    java.lang.Throwable.fillInStackTrace
  0.1%     1  +     1    sun.java2d.loops.MaskBlit.MaskBlit
  0.1%     2  +     0    java.awt.image.DataBufferInt.<init>
  0.1%     2  +     0    com.sun.imageio.plugins.png.PNGImageReader.decodePaethF
ilter
  0.0%     1  +     0    sun.font.TrueTypeFont.close
  0.0%     0  +     1    sun.awt.windows.WWindowPeer.reshapeFrame
  0.0%     1  +     0    sun.java2d.SunGraphics2D.drawImage
  0.0%     1  +     0    sun.net.www.protocol.file.Handler.createFileURLConnecti
on
  0.0%     0  +     1    java.io.RandomAccessFile.seek
  0.0%     0  +     1    sun.awt.Win32GraphicsDevice.enterFullScreenExclusive
  0.0%     0  +     1    java.lang.reflect.Array.newArray
  0.0%     0  +     1    java.io.WinNTFileSystem.list
  0.0%     1  +     0    java.awt.Rectangle.setBounds
  9.4%    43  +   251    Total interpreted (including elided)

     Compiled + native   Method
 50.7%  1591  +     0    java.awt.image.ComponentColorModel.getRGBComponent
 16.8%   529  +     0    java.awt.image.ComponentColorModel.getRGB
 15.4%   485  +     0    sun.awt.image.ByteInterleavedRaster.getDataElements
  3.5%   110  +     0    sun.java2d.loops.OpaqueCopyAnyToArgb.Blit
  1.0%    30  +     0    com.sun.imageio.plugins.png.PNGImageReader.decodePaethF
ilter
  0.2%     7  +     0    com.sun.imageio.plugins.png.PNGImageReader.decodeUpFilt
er
  0.0%     1  +     0    java.io.BufferedInputStream.read
  0.0%     1  +     0    com.sun.imageio.plugins.png.PNGImageReader.decodePass
  0.0%     1  +     0    Map.Map.paint
 87.7%  2755  +     0    Total compiled

         Stub + native   Method
  2.2%     0  +    69    sun.java2d.loops.MaskBlit.MaskBlit
  0.4%     0  +    12    java.util.zip.Inflater.inflateBytes
  0.2%     0  +     7    java.lang.System.arraycopy
  0.1%     0  +     2    java.lang.Thread.currentThread
  0.0%     0  +     1    java.io.RandomAccessFile.readBytes
  2.9%     0  +    91    Total stub

  Thread-local ticks:
  0.0%     1             Blocked (of total)
  0.0%     1             Class loader


Global summary of 34.88 seconds:
100.0%  3163             Received ticks
  0.7%    21             Received GC ticks
  0.2%     7             Compilation
  0.0%     1             Class loader

As a guess I’d say your output is listing the methods called in each running thread, the number of times it was called and the percentage of total CPU that they each used. But that is just a guess.

As an alternative I’d recommend taking a look at JVisualVM. It’ll be a lot easier then profiling via the command line. Goto the bin folder of your JDK (approximately: C:/program files/java/jdk1.6.0_17/bin) and you should see ‘jvisualvm.exe’. Run it and wait for it to open. Then run your game/app and it’ll appear listed on the left. You then double click on it to get JVisualVM to connect.

Once it’s connected you can see the memory and GC usage as well as setting it up to profile your app in greater detail.

Ok thanks, I’ll try it out now!

Edit: I have to to say this thing looks pretty cool, I’ll get back to you once I understand how to read the charts in it, for some reason the “Memory” in the profiler is taking ages to load(still not loaded) but other things look good. Thanks again for the help =)