/** * A test benchmark midlet. * (C) 2003 rhn nicholson.com * * 2003-Oct-09 */ import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class bench1midlet extends MIDlet implements CommandListener { private Command exitCommand; private TextBox tb; public String sieve(int times) { String rslt; int f[] = new int[8192]; int i,p,k,c; int s = 8192; c = 0; for (int n=0;n gap) { gap = c - lp; s = String.valueOf(c) + " " + String.valueOf(gap); } lp = c; if (p[n] * p[n] < c) n++; if (m < 999) { m++; p[m] = c; } } } } return(s); } public bench1midlet () { String s; long t0; long t1; int n; n = 10; s = "result = "; t0 = System.currentTimeMillis(); s = s + sieve(n); // run sieve benchmark t1 = System.currentTimeMillis(); s = s + " , "; s = s + String.valueOf(n) + " loops in "; s = s + String.valueOf(t1 - t0) + " mS "; tb = new TextBox("benchmark sieve 1", s , 64, 0); exitCommand = new Command("Exit", Command.EXIT, 1); tb.addCommand(exitCommand); tb.setCommandListener(this); } public void startApp() { Display.getDisplay(this).setCurrent(tb); } public void pauseApp() { } public void destroyApp( boolean unconditional ) { } // interface CommandListener public void commandAction(Command c, Displayable d) { if (c == exitCommand) { destroyApp(false); notifyDestroyed(); } } } // eof