summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-10-18 08:11:19 +0200
committerSven Gothel <[email protected]>2013-10-18 08:11:19 +0200
commit1c51abc1872b3cb984800fd76941a82dacd9e7b1 (patch)
tree1b26b1536c8b139b802573ea2a37260c51ea17b1 /src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
parent47d73819a71b7d9c4d2182a4de5712435832c5a1 (diff)
parentf1ae8ddb87c88a57dce4593f006881ef6a7f0932 (diff)
Merge remote-tracking branch 'hharrison/master'
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/FPSCounterImpl.java')
-rw-r--r--src/jogl/classes/jogamp/opengl/FPSCounterImpl.java61
1 files changed, 36 insertions, 25 deletions
diff --git a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
index b74ac9f41..08a1fe882 100644
--- a/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
+++ b/src/jogl/classes/jogamp/opengl/FPSCounterImpl.java
@@ -41,39 +41,39 @@ public class FPSCounterImpl implements FPSCounter {
private long fpsStartTime, fpsLastUpdateTime, fpsLastPeriod, fpsTotalDuration;
private int fpsTotalFrames;
private float fpsLast, fpsTotal;
-
+
/** Creates a disabled instance */
public FPSCounterImpl() {
setUpdateFPSFrames(0, null);
}
-
+
/**
* Increases total frame count and updates values if feature is enabled and
* update interval is reached.<br>
- *
+ *
* Shall be called by actual FPSCounter implementing renderer, after display a new frame.
- *
+ *
*/
public final synchronized void tickFPS() {
fpsTotalFrames++;
if(fpsUpdateFramesInterval>0 && fpsTotalFrames%fpsUpdateFramesInterval == 0) {
final long now = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
fpsLastPeriod = now - fpsLastUpdateTime;
- fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0
- fpsLast = ( (float)fpsUpdateFramesInterval * 1000f ) / ( (float) fpsLastPeriod ) ;
-
+ fpsLastPeriod = Math.max(fpsLastPeriod, 1); // div 0
+ fpsLast = ( (float)fpsUpdateFramesInterval * 1000f ) / ( (float) fpsLastPeriod ) ;
+
fpsTotalDuration = now - fpsStartTime;
fpsTotalDuration = Math.max(fpsTotalDuration, 1); // div 0
fpsTotal= ( (float)fpsTotalFrames * 1000f ) / ( (float) fpsTotalDuration ) ;
-
+
if(null != fpsOutputStream) {
fpsOutputStream.println(toString());
}
-
+
fpsLastUpdateTime = now;
}
}
-
+
public StringBuilder toString(StringBuilder sb) {
if(null==sb) {
sb = new StringBuilder();
@@ -81,22 +81,25 @@ public class FPSCounterImpl implements FPSCounter {
String fpsLastS = String.valueOf(fpsLast);
fpsLastS = fpsLastS.substring(0, fpsLastS.indexOf('.') + 2);
String fpsTotalS = String.valueOf(fpsTotal);
- fpsTotalS = fpsTotalS.substring(0, fpsTotalS.indexOf('.') + 2);
+ fpsTotalS = fpsTotalS.substring(0, fpsTotalS.indexOf('.') + 2);
sb.append(fpsTotalDuration/1000 +" s: "+ fpsUpdateFramesInterval+" f / "+ fpsLastPeriod+" ms, " + fpsLastS+" fps, "+ fpsLastPeriod/fpsUpdateFramesInterval+" ms/f; "+
"total: "+ fpsTotalFrames+" f, "+ fpsTotalS+ " fps, "+ fpsTotalDuration/fpsTotalFrames+" ms/f");
return sb;
}
-
+
+ @Override
public String toString() {
return toString(null).toString();
}
-
+
+ @Override
public final synchronized void setUpdateFPSFrames(int frames, PrintStream out) {
fpsUpdateFramesInterval = frames;
fpsOutputStream = out;
resetFPSCounter();
}
-
+
+ @Override
public final synchronized void resetFPSCounter() {
fpsStartTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); // overwrite startTime to real init one
fpsLastUpdateTime = fpsStartTime;
@@ -106,35 +109,43 @@ public class FPSCounterImpl implements FPSCounter {
fpsLastPeriod = 0; fpsTotalDuration=0;
}
+ @Override
public final synchronized int getUpdateFPSFrames() {
return fpsUpdateFramesInterval;
}
-
- public final synchronized long getFPSStartTime() {
- return fpsStartTime;
+
+ @Override
+ public final synchronized long getFPSStartTime() {
+ return fpsStartTime;
}
+ @Override
public final synchronized long getLastFPSUpdateTime() {
return fpsLastUpdateTime;
}
+ @Override
public final synchronized long getLastFPSPeriod() {
return fpsLastPeriod;
}
-
+
+ @Override
public final synchronized float getLastFPS() {
return fpsLast;
}
-
- public final synchronized int getTotalFPSFrames() {
- return fpsTotalFrames;
+
+ @Override
+ public final synchronized int getTotalFPSFrames() {
+ return fpsTotalFrames;
}
- public final synchronized long getTotalFPSDuration() {
- return fpsTotalDuration;
+ @Override
+ public final synchronized long getTotalFPSDuration() {
+ return fpsTotalDuration;
}
-
+
+ @Override
public final synchronized float getTotalFPS() {
return fpsTotal;
- }
+ }
}