aspose file tools*
The moose likes Performance and the fly likes  I don't understand these profiles - what is taking all the CPU-time? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Performance
Bookmark " I don Watch " I don New topic
Author

I don't understand these profiles - what is taking all the CPU-time?

Anders Norgaard
Greenhorn

Joined: Nov 06, 2005
Posts: 4
Hi,

http://www2.binf.ku.dk/~biehl/profile1.jpg
http://www2.binf.ku.dk/~biehl/profile2.jpg

with data (for the netbeans 5 profiler)

http://www2.binf.ku.dk/~biehl/prof1.nps
http://www2.binf.ku.dk/~biehl/prof2.nps

I don't understand where all of the cpu-time is used? Is something not inlined? What can explain such a profile?

Thanks
Anders

PS This is also posted at http://forums.java.net/jive/thread.jspa?threadID=1888&tstart=0 but that forum doesn't seem very alive.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Can you post the Protein.calcEnergy method? That's where all the time is spend...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Anders Norgaard
Greenhorn

Joined: Nov 06, 2005
Posts: 4
Here's the method - but one thing I find strange is that on from the first to the second profile i reorganized some of the methods - but then the large time consumption just moved in the call hierachy.

And also - I wonder what the time that is not marked as "self" in a method is spent on (except other methods). The numbers dont add up. "self" + "other methods" < total time.

-Anders
/**
* Calculate the entire energy for this protein. This is done by an all vs
* all check. However the energy is symmetric, so if A <-> B is done, then
* avoid B <-> A.
*
* @return whether a hard-core overlap was detected
*/
public boolean calcEnergy() {
// update the Energy

totalEnergy = 0;

boolean overlap = false;
for (int i = 0; i < ncalf; i++) {
Monomer monI = monomers[i];

for (int j = i; j < ncalf; j++) {
Monomer monJ = monomers[j];
int indexDist = Math.abs(j - i);

if (indexDist > 1 && overlap(monI, monJ)) {
overlap = true;
break;
}
totalEnergy += energyMatrix
.calcEnergy(monI, monJ, monJ.pos);
}
}
return overlap;
}
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Actually it's EnergyMatrix.calcEnergy where all the time is going, right?


[Jess in Action][AskingGoodQuestions]
Anders Norgaard
Greenhorn

Joined: Nov 06, 2005
Posts: 4
> Actually it's EnergyMatrix.calcEnergy where all the time is going, right?

Well, it depends - in profile1 it looks that way. But after a bit of code - reorg - in profile2 it is Protein.calcEnergy that takes all the time. And the really strange part is that the "EnergyMatrix.calcEnergy" that takes all the time in profile1 is the two-parameter one of the two methods below.
This is why I question if I understand the profiles correctly?

Anders


/**
* Calculate the contact energy between the two monomers
*
* @param m1
* @param m2
* @return the contact energy value
*/
public static double calcEnergy(Monomer m1, Monomer m2){
return calcEnergy(m1, m2, m2.pos);
}

/**
* Calculate the contact energy between the two monomers
*
* @param m1
* @param m2
* @param m2Pos the position to be used for m2 in stead of
* m2.pos
* @return the contact energy value
*/
public static double calcEnergy(Monomer m1, Monomer m2, Point m2Pos){
final float energy = matrix[m1.aa.ordinal()][m2.aa.ordinal()];
double dist = m1.pos.distanceTo(m2Pos);
double ddist = dist - m1.aa.size - m2.aa.size;
//TODO clean up
return energy*distanceFactor(ddist);
}
[ November 07, 2005: Message edited by: Anders Norgaard ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
It *may* be a bug in the NetBeans profiler. At least, as you I don't understand the output.
Anders Norgaard
Greenhorn

Joined: Nov 06, 2005
Posts: 4
Ok - it was a bug in the profiler - now fixed - yay!

http://forums.java.net/jive/thread.jspa?threadID=1888&tstart=0
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: I don't understand these profiles - what is taking all the CPU-time?