From 26f83388251688d5b2731ebfc067dda8be4310d9 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Fri, 22 Aug 2008 13:02:37 +0000 Subject: [PATCH] Final statistics output after the test with average speed indication. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@688078 13f79535-47bb-0310-9956-ffa450edef68 --- test/java/org/apache/fop/memory/MemoryEater.java | 4 +++- test/java/org/apache/fop/memory/Stats.java | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/test/java/org/apache/fop/memory/MemoryEater.java b/test/java/org/apache/fop/memory/MemoryEater.java index 2fdb32ac9..a665580ae 100644 --- a/test/java/org/apache/fop/memory/MemoryEater.java +++ b/test/java/org/apache/fop/memory/MemoryEater.java @@ -52,7 +52,7 @@ public class MemoryEater { 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"); @@ -61,10 +61,12 @@ public class MemoryEater { } 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()); } diff --git a/test/java/org/apache/fop/memory/Stats.java b/test/java/org/apache/fop/memory/Stats.java index 503fdad47..9e371251d 100644 --- a/test/java/org/apache/fop/memory/Stats.java +++ b/test/java/org/apache/fop/memory/Stats.java @@ -26,9 +26,12 @@ class Stats { 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; @@ -44,6 +47,7 @@ class Stats { public void notifyPagesProduced(int count) { pagesProduced += count; + totalPagesProduced += count; } public void reset() { @@ -64,6 +68,14 @@ class Stats { 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 -- 2.39.5