listing9-02_benchmark.java

来自「着几乎所有智能机厂商都将有自己配套的App Store,甚至并非智能手机制造商的」· Java 代码 · 共 26 行

JAVA
26
字号
// You can use user-defined log levels as well, such as the benchmark level:

public void run() {
	//#if polish.debug.info
		int numberOfFrames = 0;
		int framesPerSecond = 0;
		long lastFpsTime = System.currentTimeMillis();
	//#endif
	while (gameIsRunning) {
		processUserInput();
		animateWorld();
		renderWorld();
		flushGraphics();
		//#if polish.debug.info
			numberOfFrames++;
			if (System.currentTimeMillis() - lastFpsTime >= 1000) {
				lastFpsTime = System.currentTimeMillis();
				framesPerSecond = numberOfFrames;
				numberOfFrames = 0;
			}
			this.graphics.drawString( "fps=" + framesPerSecond, 0, 0,
				Graphics.TOP | Graphics.LEFT );
		//#endif
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?