// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class TestApplet extends Applet {
    private static final int N = 1000000000;
    private boolean isStandalone = false;
    public String getParameter(String key, String def) {
        return isStandalone ? System.getProperty(key, def) :
            (getParameter(key) != null ? getParameter(key) : def);
    }
    public SpeedTest() {
    }
    public void init() {
        try {
            jbInit();
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    private void jbInit() throws Exception {
        long t1 = System.currentTimeMillis();
        int sum = 0;
        for(int i = 0; i < N; i++) {
            sum = ((sum + 1) * 2 + 1) / 2;
        }
        long t2 = System.currentTimeMillis();
        TextArea txt = new TextArea(1, 40);
        txt.setText(N + " operations in " + ((t2 - t1) / 1000) + " seconds");
        this.add(txt, null);
    }
    public String getAppletInfo() {
        return "Applet Information";
    }
    public String[][] getParameterInfo() {
        return null;
    }
}
