📄 multiplier.java
字号:
/* * Multiplier.java * * Created on den 2 juli 2003, 17:04 */package DXBenchmarker;import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;import java.io.IOException;/** * * @author 23046803 * @version */public class Multiplier extends Form implements CommandListener{ private static final Command exitCommand = new Command("Exit", Command.EXIT, 2); private static final Command okCommand = new Command("OK", Command.OK, 2); private static final int NUMBER_OF_LOOPS = 1000000; private long startTime; private long endTime; private long totalTime; private Display display; private Displayable previousDisplay; public Multiplier(Display display, Displayable previousDisplay) { super("Multiplier application"); this.addCommand(exitCommand); this.addCommand(okCommand); this.setCommandListener(this); this.display = display; this.previousDisplay = previousDisplay; showStartForm(); } public void commandAction(Command c, Displayable s) { if (c == exitCommand) { display.setCurrent(previousDisplay); } if (c == okCommand) { showPleaseWait(); makeMultiplications(); } } public void showStartForm() { this.append("This test will now run a set of multiplications, depending upon the platform the test may take as much as one minute!"); } public synchronized void showPleaseWait() { while (this.size() > 0) { delete(0); } this.append("Please wait \n"); this.append("Making calculations (this could take one minute)"); } public synchronized void makeMultiplications() { int numberOfMultiplications = 0; int a = 1000; int b = 1; startTime = System.currentTimeMillis(); for (int x = 0; x < NUMBER_OF_LOOPS; x = x + 1) { a = b * 0; a = b * 1; a = b * 2; a = b * 3; a = b * 4; a = b * 5; a = b * 6; a = b * 7; a = b * 8; a = b * 9; } endTime = System.currentTimeMillis(); totalTime = endTime - startTime; numberOfMultiplications = 10 * NUMBER_OF_LOOPS; while (this.size() > 0) { delete(0); } this.append("Total time (ms): " + totalTime + "\n"); this.append("Multiplications: " + numberOfMultiplications + "\n"); this.append("Multiplications / millisecond: " + numberOfMultiplications / totalTime + "\n"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -