listing16-02_measuringperformanceingameloop.txt

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

TXT
31
字号
// Listing 16-2.Measuring the Performance of a Typical Game Loop

public void run() {
	while ( this.gameIsRunning ) {
		evaluateUserInput();

		//#if polish.debug.benchmark
			long startTime = System.currentTimeMillis();
			for ( int i = 0; i < 100; i++ ) {
		//#endif
		animateWorld();
		//#if polish.debug.benchmark
			}
			long timeAnimate = System.currentTimeMillis() - startTime;
		//#endif
		//#if polish.debug.benchmark
			startTime = System.currentTimeMillis();
			for ( int i = 0; i < 100; i++ ) {
		//#endif

		renderWorld();

		//#if polish.debug.benchmark
			}
			long timeRender = System.currentTimeMillis() - startTime;
			//#debug benchmark
			System.out.println( "animateWorld: " + timeAnimate + "renderWorld: " + timeRender );
		//#endif
	}
}

⌨️ 快捷键说明

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