Lucy,
I can't really answer your question, but I have some code I can offer that I
use for monitoring frames/second. I would be interested in hearing comments
from this group as to the correctness/efficiency of my method. It seems to
work OK, but if there is a better way, please let's here it!
// This behavior calculates the frame rate every N frames, I currently have
N=50. There are artifacts in using this method that increase when frame rates
are low.
// The "statuspane" container needs to be accessible, I use a global, see
definition below.
private class FPSBehavior extends Behavior
{
WakeupCondition FPSCriterion;
Date last;
int nframes = 50;
public FPSBehavior()
{
super();
}
public void initialize()
{
WakeupCriterion crit = new WakeupOnElapsedFrames( nframes );
FPSCriterion = crit;
last = new Date(); // Get start time
wakeupOn( FPSCriterion );
}
public void processStimulus( Enumeration criteria )
{
// Calculate elapsed time in milliseconds since last wakeup.
Date current = new Date();
long elapsedms = current.getTime() - last.getTime();
last = current;
double FPS = ((double) nframes) / ((double) elapsedms) * 1000.0;
statuspane.setFPS( (int)(FPS + 0.5) );
wakeupOn( FPSCriterion );
}
}
// Display Frames/Second. (This installs the above behavior)
FPSBehavior fpsBehavior = new FPSBehavior();
fpsBehavior.setSchedulingBounds( bounds );
addChild( fpsBehavior );
// This container displays the current frame rate. NOTE: Lbl is just a
customized JLabel, the AWT Label should work as well.
private class StatusPane extends JPanel
{
private Lbl fpsValue;
public StatusPane()
{
setBorder( BorderFactory.createBevelBorder(BevelBorder.LOWERED) );
// Add a frame rate display:
Lbl fpsLabel = new Lbl( "Frame Rate: " );
fpsValue = new Lbl();
Lbl fpsUnits = new Lbl( "fps" );
add( fpsLabel );
add( fpsValue );
add( fpsUnits );
}
public void setFPS( int FPS )
{
fpsValue.setText( Integer.toString( FPS ) );
}
}
// Add status pane: (This installs the container and initializes the frame
rate display)
statuspane = new StatusPane();
statuspane.setFPS( 0 );
toppane.add( statuspane, BorderLayout.SOUTH );
Lucy Boyd-Wilson <[EMAIL PROTECTED]> on 03/09/99 05:29:06 PM
To: [EMAIL PROTECTED]
cc: (bcc: Gary Moss/arl)
Subject: [java3d] Refresh rate / performance monitoring
I must be missing something obvious but ....
how do you do performance monitoring of the display thread in a Java3d
application.
At the minimum I'd like to get the refresh rate, and would be interested in
other statistics too if they are available (such as # of polys displayed).
Are there any tools provided for this?
Or is there a way to insert time/polygon counting code into the display
thread?
lucy
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/