private FopFactory fopFactory = FopFactory.newInstance();
private Templates replicatorTemplates;
- private Stats stats = new Stats();
+ private Stats stats;
public MemoryEater() throws TransformerConfigurationException, MalformedURLException {
File xsltFile = new File("test/xsl/fo-replicator.xsl");
}
private void eatMemory(File foFile, int runRepeats, int replicatorRepeats) throws Exception {
+ stats = new Stats();
for (int i = 0; i < runRepeats; i++) {
eatMemory(i, foFile, replicatorRepeats);
stats.progress(i, runRepeats);
}
+ stats.dumpFinalStats();
System.out.println(stats.getGoogleChartURL());
}
private static final int INTERVAL = 2000;
- private long lastProgressDump = System.currentTimeMillis();
+ private long startTime = System.currentTimeMillis();
+ private long lastProgressDump = startTime;
private int pagesProduced;
+ private int totalPagesProduced;
+
private int step;
private int stepCount;
public void notifyPagesProduced(int count) {
pagesProduced += count;
+ totalPagesProduced += count;
}
public void reset() {
samples.add(new Sample((int)ppm));
}
+ public void dumpFinalStats() {
+ long duration = System.currentTimeMillis() - startTime;
+ System.out.println("Final statistics");
+ System.out.println("Pages produced: " +totalPagesProduced);
+ long ppm = 60000 * totalPagesProduced / duration;
+ System.out.println("Average speed: " + ppm + "ppm");
+ }
+
public String getGoogleChartURL() {
StringBuffer sb = new StringBuffer("http://chart.apis.google.com/chart?");
//http://chart.apis.google.com/chart?cht=ls&chd=t:60,40&chs=250x100&chl=Hello|World