Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (108)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  which java profiler?  (Read 1783 times)
0 Members and 1 Guest are viewing this topic.
Offline SDV

Senior Newbie





« Posted 2005-04-04 14:41:51 »

im currently searching for performance bottlenecks so if tryed the trial of jprofiler but i have a lot inner loops wich call some get methods and the cpu profiling vom jprofiler seems to give realy wrong info about whats happening there :/ (more info: see below)

so what im searching is a profiler wich can give me exact information about whats uses a lot cpu-time and what not... especialy in inner loops wich are processed some thousend times per frame
it would be perfect if it is freeware or at least free for non comercial use....

so wich profiler do u use?
or wich would u suggest to try out?


//-------------------------------
my problem with jprofiler:
as i said method calls in inner loops are profiled very wrong (it seems the profiler counts its own overheat)

my testscenario in short (full code at the bottom):
-one method (perGetter()) wich gets the data out of an object over the get method
-one method (direct()) wich breaks the oop style and directly accesses the membervariables
both iterate over a larg array filled with test objects


results by manualy checking the time before and after such a method call:
getter time:1.093902716 sec
direct time:1.104081944 sec

getter time:1.057655652 sec
direct time:1.0200114820000001 sec

getter time:1.214332269 sec
direct time:1.061467309 sec


jprofiler tells me that perGetter() uses 95% cpu time and direct() 5%
well thats a too big mistake so that it is realy impossible to work with this profiler :/

the testscenario:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
import java.util.Random;

class helper{
      int a;
      byte b;
      float c;
      double d;
     
      static int MULTIPLY = 50000;
      static Random rand = new Random();
     
      public helper() {
            a=rand.nextInt(MULTIPLY);
            b=(byte)(0xFF&rand.nextInt());
            c=rand.nextFloat()*MULTIPLY;
            d=rand.nextDouble()*MULTIPLY;
      }

      public int getA() {
            return a;
      }
      public byte getB() {
            return b;
      }
      public float getC() {
            return c;
      }
      public double getD() {
            return d;
      }
     
}


public class profilerTest {
      static helper h[];

      static long t1,t2,t3;
      static double d1=0,d2=0;
     
      static int repeats = 5;
     
      public static void main(String[] args) {
            for (int i=0;i<3;i++){
                  makeArray(1000000);
                 
                  test();
            }
           
            //wait forever
           while(true){
                  try {
                        Thread.sleep(Integer.MAX_VALUE);
                  } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                       e.printStackTrace();
                  }
            }

      }
     
      static void test(){
            d1=d2=0;
           
            t1=System.nanoTime();
           
            for(int j = 0; j<repeats;j++)
                  d1+=perGetter();
           
            t2=System.nanoTime();
           
            for(int j = 0; j<repeats;j++)
                  d2+=direct();
           
            t3=System.nanoTime();
           
            System.out.println("getter:"+d1+" \t\ttime:"+
            ((t2-t1)*1e-9));
            System.out.println("direct:"+d2+" \t\ttime:"+
            ((t3-t2)*1e-9));
            System.out.println();

      }
     
      static double perGetter(){
            double ret =0 ;
            for (helper i : h) {
                  ret-=i.getA();
                  ret+=i.getB();
                  ret-=i.getC();
                  ret+=i.getD();
            }
            return ret;
      }
     
      static double direct(){
            double ret =0 ;
            for (helper i : h) {
                  ret-=i.a;
                  ret+=i.b;
                  ret-=i.c;
                  ret+=i.d;
            }
            return ret;
      }
     
      static void makeArray(int count){
            h=new helper[count];
            for (int i=0; i<count; i++) {
                  h[i]=new helper();
            }
      }

}
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #1 - Posted 2005-04-04 14:56:03 »

Personally, i love yourkit.com profiler:

http://www.yourkit.com

Simply rocks! Dont know about number reliability tho and stuff like that...

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #2 - Posted 2005-04-04 15:25:07 »

I just ran your test with yourkit.com

my results:

Quote

getter:-1.2473789323630396E11             time:0.513188967
direct:-1.2473789323630396E11             time:0.346668641

getter:-1.2508688547315341E11             time:0.340193795
direct:-1.2508688547315341E11             time:0.31419384300000003

getter:-1.2504620170303958E11             time:0.336666252
direct:-1.2504620170303958E11             time:0.298912292


And this is what it said:

direct() uses 12% of the CPU
perGetter() uses 16% of the CPU
makeArray(int) uses 71% of the CPU, 58% of that goes to the Helper class and 100% of that goes to Random.nextXXX() call.

Are those the results you expected?

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #3 - Posted 2005-04-04 15:46:50 »

Quote
Personally, i love yourkit.com profiler:

http://www.yourkit.com

Simply rocks! Dont know about number reliability tho and stuff like that...

DP


500$. lol.

Here is a nice list of open source profilers:
http://www.manageability.org/blog/stuff/open-source-profilers-for-java/view

弾幕 ☆ @mahonnaiseblog
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #4 - Posted 2005-04-04 15:52:22 »

since he was using JProfiler, i assumed he wanted commercial quality stuff... Grin

But seriously, yourkit.com is awsome and well worth the email if you have an opensource project  Smiley

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #5 - Posted 2005-04-04 16:03:14 »

Yea... but who wants to use several sets of tools? I rather don't use it at all then.

It's yet another example of bad market segmentation. The big corporations with lots of money get it really cheap. Only 2350$ for an unlimited license. That means 2.25$ for each of your 1000 machines.

And the small independent developer has to pay 500 bucks for it. Wow. That's like so smart.

[BTW this thread should be over at the tools forum]

弾幕 ☆ @mahonnaiseblog
Offline SDV

Senior Newbie





« Reply #6 - Posted 2005-04-04 19:56:27 »

Quote
direct() uses 12% of the CPU
perGetter() uses 16% of the CPU
makeArray(int) uses 71% of the CPU, 58% of that goes to the Helper class and 100% of that goes to Random.nextXXX() call.

that means that direct uses 42%
and perGetter 58% das looks much much better....
but well 500$$.... (oww i see that jprofiler also costs 400$)
ill have to look for those free ones..... especialy cause i wont use it for commercial development.... and also dont have a open source project to show....

so are there some other open source profilers wich u can suggest?
ill now take a look at those suggestet from oNyx

thx for your answers
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #7 - Posted 2005-04-04 21:13:28 »

well, if you have an opensource project that as an active community, you can email yourkit.com and they will send you a license for their profiler.

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline vrm

Junior Member




where I should sign ?


« Reply #8 - Posted 2005-04-05 07:43:37 »

I use this eclipse plugin, enougth for me Smiley
http://eclipsecolorer.sourceforge.net/index_profiler.html

heard a lot of good about yourkit, but never tried (500$ .. ekk)
Offline SDV

Senior Newbie





« Reply #9 - Posted 2005-04-05 13:16:33 »

@dark prophed
all i have is a private project wich will hopefully see daylight before 2010 (or hopefully will see it ever)

thx to Ken Russel iv found out that there are 2 build in profilers in the jvm one is -Xprof the other one is -agentlib:hprof wich is much more complex than the first one.. ill have to test if its usefull or not...
also hes suggested JFluid but it seems its called now The NetBeans Profiler Project.... and it seems it can only profile 1.4 bytecode... but im using heavily 1.5 stuff like templates or whatever :/

iv now tested -agentlib:hprof a bit and it seems that it also gives very wrong output with cpu timing enabled but ok output with sampling (but however sampling is not realy accurate because of the way its done :/)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Matlu

Junior Member




Hasta La Victoria Siempre!


« Reply #10 - Posted 2005-04-12 20:11:16 »

Quote
I use this eclipse plugin, enougth for me Smiley
http://eclipsecolorer.sourceforge.net/index_profiler.html


I tried it and I like it, seems to be good piece of software.
BTW have you tried profiling java api classes? I would especially like to know how often is called new String()  It should be possible, I tried to set up filters, but I just could not get it working. For my own classes it works very well. If you have some time please try it.

Multiplayer Online Games
http://www.duelboard.com
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (16 views)
2014-07-30 21:08:39

Riven (22 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (33 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!