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:
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();
}
}
}
