aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache
diff options
context:
space:
mode:
authorOleg Tkachenko <olegt@apache.org>2002-12-18 23:09:28 +0000
committerOleg Tkachenko <olegt@apache.org>2002-12-18 23:09:28 +0000
commit0a79c7c43d01365646d0bfbb1b50525a306ced7c (patch)
tree7bed7714312266e75a466fe40d8629b9b66057e0 /src/org/apache
parent82016acb52a3177d3a1e164608e143e11b1ce5c6 (diff)
downloadxmlgraphics-fop-0a79c7c43d01365646d0bfbb1b50525a306ced7c.tar.gz
xmlgraphics-fop-0a79c7c43d01365646d0bfbb1b50525a306ced7c.zip
Cleaned up unused imports, made collection of the statistics optional.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195779 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache')
-rw-r--r--src/org/apache/fop/apps/LayoutHandler.java76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/org/apache/fop/apps/LayoutHandler.java b/src/org/apache/fop/apps/LayoutHandler.java
index efe7e30f2..3ea82f855 100644
--- a/src/org/apache/fop/apps/LayoutHandler.java
+++ b/src/org/apache/fop/apps/LayoutHandler.java
@@ -7,42 +7,43 @@
package org.apache.fop.apps;
+// Java
import java.io.OutputStream;
import java.io.IOException;
-import java.util.HashSet;
import java.util.List;
+// SAX
import org.xml.sax.SAXException;
+// FOP
import org.apache.fop.layout.FontInfo;
-import org.apache.fop.area.PageViewport;
import org.apache.fop.area.AreaTree;
-import org.apache.fop.area.CachedRenderPagesModel;
import org.apache.fop.area.Title;
import org.apache.fop.area.TreeExt;
import org.apache.fop.render.Renderer;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.LayoutMasterSet;
-import org.apache.avalon.framework.logger.Logger;
-
/**
* Layout handler that receives the structure events.
* This initiates layout processes and corresponding
* rendering processes such as start/end.
*/
public class LayoutHandler extends StructureHandler {
- private static final boolean MEM_PROFILE_WITH_GC = false;
+
+ // TODO: Collecting of statistics should be configurable
+ private final boolean collectStatistics = true;
+ private final boolean MEM_PROFILE_WITH_GC = false;
/**
Somewhere to get our stats from.
*/
- private Runtime runtime = Runtime.getRuntime();
+ private Runtime runtime;
/**
Keep track of the number of pages rendered.
*/
- int pageCount = 0;
+ private int pageCount;
/**
Keep track of heap memory allocated,
@@ -87,6 +88,8 @@ public class LayoutHandler extends StructureHandler {
*/
public LayoutHandler(OutputStream outputStream, Renderer renderer,
boolean store) {
+ if (collectStatistics)
+ runtime = Runtime.getRuntime();
this.outputStream = outputStream;
this.renderer = renderer;
@@ -112,15 +115,15 @@ public class LayoutHandler extends StructureHandler {
* @throws SAXException if there is an error
*/
public void startDocument() throws SAXException {
- pageCount = 0;
-
- if (MEM_PROFILE_WITH_GC) {
- System.gc(); // This takes time but gives better results
+ //Initialize statistics
+ if (collectStatistics) {
+ pageCount = 0;
+ if (MEM_PROFILE_WITH_GC) {
+ System.gc(); // This takes time but gives better results
+ }
+ initialMemory = runtime.totalMemory() - runtime.freeMemory();
+ startTime = System.currentTimeMillis();
}
-
- initialMemory = runtime.totalMemory() - runtime.freeMemory();
- startTime = System.currentTimeMillis();
-
try {
renderer.setupFontInfo(fontInfo);
// check that the "any,normal,400" font exists
@@ -147,30 +150,27 @@ public class LayoutHandler extends StructureHandler {
throw new SAXException(e);
}
- if (getLogger().isDebugEnabled()) {
+ if (collectStatistics) {
if (MEM_PROFILE_WITH_GC) {
// This takes time but gives better results
System.gc();
}
-
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
long memoryUsed = (memoryNow - initialMemory) / 1024L;
- getLogger().debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
- getLogger().debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
- getLogger().debug("Total memory used: " + memoryUsed + "Kb");
-
- if (!MEM_PROFILE_WITH_GC) {
- getLogger().debug(" Memory use is indicative; no GC was performed");
- getLogger().debug(" These figures should not be used comparatively");
- }
- }
-
- if (getLogger().isDebugEnabled()) {
long timeUsed = System.currentTimeMillis() - startTime;
- getLogger().debug("Total time used: " + timeUsed + "ms");
- getLogger().debug("Pages rendered: " + pageCount);
- if (pageCount > 0) {
- getLogger().debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
+ getLogger().debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
+ getLogger().debug("Total memory used: " + memoryUsed + "Kb");
+ if (!MEM_PROFILE_WITH_GC) {
+ getLogger().debug(" Memory use is indicative; no GC was performed");
+ getLogger().debug(" These figures should not be used comparatively");
+ }
+ getLogger().debug("Total time used: " + timeUsed + "ms");
+ getLogger().debug("Pages rendered: " + pageCount);
+ if (pageCount > 0) {
+ getLogger().debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
+ }
}
}
}
@@ -204,16 +204,16 @@ public class LayoutHandler extends StructureHandler {
throws FOPException {
//areaTree.setFontInfo(fontInfo);
- if (getLogger().isDebugEnabled()) {
+ if (collectStatistics) {
if (MEM_PROFILE_WITH_GC) {
// This takes time but gives better results
System.gc();
}
-
long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- getLogger().debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
+ }
}
-
pageSequence.format(areaTree);
}
@@ -235,7 +235,7 @@ public class LayoutHandler extends StructureHandler {
for (int c = 0; c < pagec; c++) {
try {
renderer.renderPage(model.getPage(count, c));
- } catch (java.io.IOException ioex) {
+ } catch (IOException ioex) {
throw new FOPException("I/O Error rendering page",
ioex);
}