6 import java.awt.image.*;
7 import java.awt.event.*;
20 long fps, startTime, elapsedTime;
27 int max = 12*1204*1024;
28 long maxMemory =
IJ.maxMemory();
30 public void run(String arg) {
36 ip =
new ByteProcessor(width, height,
new byte[width*height], null);
37 ip.setColor(Color.white);
39 ip.setColor(Color.black);
40 ip.setFont(
new Font(
"SansSerif",Font.PLAIN,12));
41 ip.setAntialiasedText(
true);
47 mem =
new float[width+1];
48 Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
49 startTime = System.currentTimeMillis();
54 double value2 = (double)value/1048576L;
55 String s =
IJ.
d2s(value2,value2>50?0:2)+
"MB";
57 double percent = value*100/maxMemory;
58 s +=
" ("+(percent<1.0?
"<1":
IJ.
d2s(percent,0)) +
"%)";
61 elapsedTime = System.currentTimeMillis()-startTime;
63 double scale = ic.getMagnification();
64 fps = (frames*10000)/elapsedTime;
65 s +=
", " + fps/10 +
"." + fps%10 +
" fps";
73 long freeMem = Runtime.getRuntime().freeMemory();
74 long totMem = Runtime.getRuntime().totalMemory();
75 return totMem-freeMem;
79 long used = memoryInUse();
80 if (frames%10==0) value=used;
81 if (used>0.9*max) max*=2;
82 mem[index++] = (float)used;
83 if (index==mem.length) index = 0;
86 if (index2==mem.length) index2 = 0;
87 double scale = (double)height/max;
88 ip.moveTo(0, height-(
int)(mem[index2]*scale));
89 for (
int x=1; x<width; x++) {
91 if (index2==mem.length) index2 = 0;
92 ip.lineTo(x, height-(
int)(mem[index2]*scale));