import java.io.*;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Font;
import java.awt.FontMetrics;
import java.util.StringTokenizer;

public class BenchmarkApplet extends java.applet.Applet {

  Font courier = new Font("Courier", Font.BOLD, 14);  // For tabular formatting
  ByteArrayOutputStream bostream = new ByteArrayOutputStream();
  PrintStream pstream = new PrintStream(bostream);
  Benchmark bm = null;
  int paintcount = 0;
  int skipval;

public void init() {
    setFont(courier);
    skipval = getFontMetrics(courier).getHeight();
//    setBackground(Color.white);  // Trying to avoid color-not-found warning
    bm = new Benchmark(pstream);
}

public void start() {
    while (bm.nextTest()) repaint();
}

public void paint(Graphics g) {
//    g.drawString("Painted " + ++paintcount + "; skipval = " + skipval, 5, 10);

    StringTokenizer tokenizer = new StringTokenizer(bostream.toString(), "\n");
    for (int ypos = 10 + skipval ; tokenizer.hasMoreTokens() ; ypos += skipval)
      g.drawString(tokenizer.nextToken(), 5, ypos);
 }

} // end class BenchmarkApplet
