/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package com.badlogic.gdx.graphics;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.TimeUtils;

/** A simple helper class to log the frames per seconds achieved. Just invoke the {@link #log()} method in your rendering method.
 * The output will be logged once per second.
 * 
 * @author mzechner */
public class FPSLogger {
	long startTime;

	public FPSLogger () {
		startTime = TimeUtils.nanoTime();
	}

	/** Logs the current frames per second to the console. */
	public void log () {
		if (TimeUtils.nanoTime() - startTime > 1000000000) /* 1,000,000,000ns == one second */{
			Gdx.app.log("FPSLogger", "fps: " + Gdx.graphics.getFramesPerSecond());
			startTime = TimeUtils.nanoTime();
		}
	}
}

@@ -1129,16 +1129,29 @@
 rtTime;%0D
+%0A%09int bound;%0D
 %0A%0D%0A%09publ
@@ -1169,16 +1169,190 @@
 r () %7B%0D%0A
+%09%09this(Integer.MAX_VALUE);%0D%0A%09%7D%0D%0A%0D%0A%09/** @param bound only logs when they frames per second are less than the bound */%0D%0A%09public FPSLogger (int bound) %7B%0D%0A%09%09this.bound = bound;%0D%0A
 %09%09startT
@@ -1475,12 +1475,30 @@
 %0D%0A%09%09
-if (
+final long nanoTime = 
 Time
@@ -1513,16 +1513,33 @@
 noTime()
+;%0D%0A%09%09if (nanoTime
  - start
@@ -1546,22 +1546,25 @@
 Time %3E 1
+_
 000
+_
 000
+_
 000) /* 
@@ -1599,86 +1599,137 @@
 d */
+ 
 %7B%0D%0A%09%09%09
-Gdx.app.log(%22FPSLogger%22, %22fps: %22 + Gdx.graphics.getFramesPerSecond()
+final int fps = Gdx.graphics.getFramesPerSecond();%0D%0A%09%09%09if (fps %3C bound) %7B%0D%0A%09%09%09%09Gdx.app.log(%22FPSLogger%22, %22fps: %22 + fps
 );%0D%0A
+%09
 %09%09%09s
@@ -1739,34 +1739,24 @@
 tTime = 
-TimeUtils.
 nanoTime
 ();%0D%0A%09%09%7D
@@ -1743,27 +1743,31 @@
 e = nanoTime
-();
+;%0D%0A%09%09%09%7D
 %0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D

Support for an upper bound (#6069)