public void display() {
      int iter = 0, seed = 0;
      double tStart, t1, t2, paintTime = 0.;
      tStart = getTime();
      if (width != getWidth() || height != getHeight()) {
        im.resize(getWidth(), getHeight());
        width = getWidth();  height = getHeight();
      }
      System.out.format("Window size: %d x %d\n", width, height);

      while (true) {
        initImage(width, height, seed++);
        t1 = getTime();
        paintImmediately(0, 0, width, height);
        t2 = getTime();
        paintTime += t2 - t1;
        iter++;
        if (t2 - tStart > 5.0) {
          System.out.format("%f Mpixels/sec\n",
            (double)iter * (double)(width * height) / (1000000. * paintTime));
          paintTime = 0.;
          tStart = getTime();
          iter = 0;
        }
      }
    }