aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas/performance
diff options
context:
space:
mode:
authornetconomy <netconomy@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-08-17 06:10:56 +0000
committernetconomy <netconomy@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2007-08-17 06:10:56 +0000
commit3d982813b34f6f230baf4a467cdc37ec92a77595 (patch)
tree85319d39cee2ded1bb7a2b2dd9e8ea37e3778248 /src/main/java/at/gv/egiz/pdfas/performance
parent07f6c8f33b2d700276fe6ec6339ff836c8710131 (diff)
downloadpdf-as-3-3d982813b34f6f230baf4a467cdc37ec92a77595.tar.gz
pdf-as-3-3d982813b34f6f230baf4a467cdc37ec92a77595.tar.bz2
pdf-as-3-3d982813b34f6f230baf4a467cdc37ec92a77595.zip
Performance
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@167 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas/performance')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounter.java62
-rw-r--r--src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounters.java22
-rw-r--r--src/main/java/at/gv/egiz/pdfas/performance/PerformanceTimer.java48
3 files changed, 132 insertions, 0 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounter.java b/src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounter.java
new file mode 100644
index 0000000..2d9b461
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounter.java
@@ -0,0 +1,62 @@
+/**
+ *
+ */
+package at.gv.egiz.pdfas.performance;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author wprinz
+ */
+public class PerformanceCounter
+{
+ /**
+ * The log.
+ */
+ private static Log log = LogFactory.getLog(PerformanceCounter.class);
+
+ protected String name = null;
+
+ protected long counter = 0;
+
+ public PerformanceCounter(String name)
+ {
+ this.name = name;
+ reset();
+ }
+
+ public PerformanceCounter(Class clazz)
+ {
+ this(clazz.getName());
+ }
+
+ public void increment()
+ {
+ this.counter++;
+ log.trace(this.name + ": incremented to " + this.counter);
+ }
+
+ public void reset()
+ {
+ this.counter = 0;
+ log.trace(this.name + ": reset to 0");
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName()
+ {
+ return this.name;
+ }
+
+ /**
+ * @return the counter
+ */
+ public long getCounter()
+ {
+ return this.counter;
+ }
+
+}
diff --git a/src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounters.java b/src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounters.java
new file mode 100644
index 0000000..6251c55
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/performance/PerformanceCounters.java
@@ -0,0 +1,22 @@
+/**
+ *
+ */
+package at.gv.egiz.pdfas.performance;
+
+/**
+ * Contains various global PerformanceCounters that provide information about the system.
+ *
+ * @author wprinz
+ */
+public final class PerformanceCounters
+{
+ /**
+ * Keeps track of the number of text extractions done so far.
+ */
+ public static PerformanceCounter textExtractions = new PerformanceCounter("TextExtractions");
+
+ /**
+ * Keeps track of the number of large byte array allocations.
+ */
+ public static PerformanceCounter byteArrays = new PerformanceCounter("ByteArrays");
+}
diff --git a/src/main/java/at/gv/egiz/pdfas/performance/PerformanceTimer.java b/src/main/java/at/gv/egiz/pdfas/performance/PerformanceTimer.java
new file mode 100644
index 0000000..6ebb9be
--- /dev/null
+++ b/src/main/java/at/gv/egiz/pdfas/performance/PerformanceTimer.java
@@ -0,0 +1,48 @@
+/**
+ *
+ */
+package at.gv.egiz.pdfas.performance;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author wprinz
+ *
+ */
+public class PerformanceTimer
+{
+ /**
+ * The log.
+ */
+ private static Log log = LogFactory.getLog(PerformanceTimer.class);
+
+ protected String name = null;
+
+ protected long startTime = -1;
+
+ protected long stopTime = -1;
+
+ public PerformanceTimer(String name)
+ {
+ this.name = name;
+ }
+
+ public void start()
+ {
+ this.startTime = System.currentTimeMillis();
+ log.trace(this.name + ": started at " + this.startTime);
+ }
+
+ public void stop()
+ {
+ this.stopTime = System.currentTimeMillis();
+ log.trace(this.name + ": stopped at " + this.stopTime);
+ log.trace(this.name + ": time elapsed = " + getTimeElapsed());
+ }
+
+ public long getTimeElapsed()
+ {
+ return this.stopTime - this.startTime;
+ }
+}