diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Simple-jdbc-statistics.iml b/Simple-jdbc-statistics.iml
index ca90a9b..d61fca5 100644
--- a/Simple-jdbc-statistics.iml
+++ b/Simple-jdbc-statistics.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Simple-jdbc-statistics.iml b/Simple-jdbc-statistics.iml
index ca90a9b..d61fca5 100644
--- a/Simple-jdbc-statistics.iml
+++ b/Simple-jdbc-statistics.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java
index c409b54..0d222e2 100644
--- a/src/nl/astraeus/jdbc/JdbcLogger.java
+++ b/src/nl/astraeus/jdbc/JdbcLogger.java
@@ -5,7 +5,6 @@
import org.slf4j.LoggerFactory;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
/**
* User: riennentjes
@@ -37,6 +36,17 @@
this.sql = sql;
this.milli = milli;
this.nano = nano;
+ this.count = 1;
+ }
+
+ public LogEntry(LogEntry le) {
+ this.timeStamp = System.currentTimeMillis();
+ this.hash = le.hash;
+ this.type = le.type;
+ this.sql = le .sql;
+ this.milli = le.milli;
+ this.nano = le.nano;
+ this.count = le.count;
}
public int getCount() {
@@ -64,11 +74,11 @@
}
public String getFormattedMilli() {
- return Util.formatNano(milli*1000000);
+ return Util.formatNano(milli*1000000/count);
}
public String getFormattedNano() {
- return Util.formatNano(nano);
+ return Util.formatNano(nano/count);
}
public String getTotal() {
@@ -78,6 +88,13 @@
public String getSql() {
return sql;
}
+
+ public void addCount(LogEntry le) {
+ count++;
+ this.milli += le.getMilli();
+ this.nano += le.getNano();
+ this.timeStamp = 0;
+ }
}
private final List queries;
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Simple-jdbc-statistics.iml b/Simple-jdbc-statistics.iml
index ca90a9b..d61fca5 100644
--- a/Simple-jdbc-statistics.iml
+++ b/Simple-jdbc-statistics.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java
index c409b54..0d222e2 100644
--- a/src/nl/astraeus/jdbc/JdbcLogger.java
+++ b/src/nl/astraeus/jdbc/JdbcLogger.java
@@ -5,7 +5,6 @@
import org.slf4j.LoggerFactory;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
/**
* User: riennentjes
@@ -37,6 +36,17 @@
this.sql = sql;
this.milli = milli;
this.nano = nano;
+ this.count = 1;
+ }
+
+ public LogEntry(LogEntry le) {
+ this.timeStamp = System.currentTimeMillis();
+ this.hash = le.hash;
+ this.type = le.type;
+ this.sql = le .sql;
+ this.milli = le.milli;
+ this.nano = le.nano;
+ this.count = le.count;
}
public int getCount() {
@@ -64,11 +74,11 @@
}
public String getFormattedMilli() {
- return Util.formatNano(milli*1000000);
+ return Util.formatNano(milli*1000000/count);
}
public String getFormattedNano() {
- return Util.formatNano(nano);
+ return Util.formatNano(nano/count);
}
public String getTotal() {
@@ -78,6 +88,13 @@
public String getSql() {
return sql;
}
+
+ public void addCount(LogEntry le) {
+ count++;
+ this.milli += le.getMilli();
+ this.nano += le.getNano();
+ this.timeStamp = 0;
+ }
}
private final List queries;
diff --git a/src/nl/astraeus/jdbc/util/Util.java b/src/nl/astraeus/jdbc/util/Util.java
index eaa853b..44ce8c8 100644
--- a/src/nl/astraeus/jdbc/util/Util.java
+++ b/src/nl/astraeus/jdbc/util/Util.java
@@ -11,7 +11,7 @@
public class Util {
// utility functions
public static String formatNano(long l) {
- NumberFormat format = new DecimalFormat("###,##0.000000");
+ NumberFormat format = new DecimalFormat("###,##0.000");
return format.format((double) l / 1000000.0);
}
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Simple-jdbc-statistics.iml b/Simple-jdbc-statistics.iml
index ca90a9b..d61fca5 100644
--- a/Simple-jdbc-statistics.iml
+++ b/Simple-jdbc-statistics.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java
index c409b54..0d222e2 100644
--- a/src/nl/astraeus/jdbc/JdbcLogger.java
+++ b/src/nl/astraeus/jdbc/JdbcLogger.java
@@ -5,7 +5,6 @@
import org.slf4j.LoggerFactory;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
/**
* User: riennentjes
@@ -37,6 +36,17 @@
this.sql = sql;
this.milli = milli;
this.nano = nano;
+ this.count = 1;
+ }
+
+ public LogEntry(LogEntry le) {
+ this.timeStamp = System.currentTimeMillis();
+ this.hash = le.hash;
+ this.type = le.type;
+ this.sql = le .sql;
+ this.milli = le.milli;
+ this.nano = le.nano;
+ this.count = le.count;
}
public int getCount() {
@@ -64,11 +74,11 @@
}
public String getFormattedMilli() {
- return Util.formatNano(milli*1000000);
+ return Util.formatNano(milli*1000000/count);
}
public String getFormattedNano() {
- return Util.formatNano(nano);
+ return Util.formatNano(nano/count);
}
public String getTotal() {
@@ -78,6 +88,13 @@
public String getSql() {
return sql;
}
+
+ public void addCount(LogEntry le) {
+ count++;
+ this.milli += le.getMilli();
+ this.nano += le.getNano();
+ this.timeStamp = 0;
+ }
}
private final List queries;
diff --git a/src/nl/astraeus/jdbc/util/Util.java b/src/nl/astraeus/jdbc/util/Util.java
index eaa853b..44ce8c8 100644
--- a/src/nl/astraeus/jdbc/util/Util.java
+++ b/src/nl/astraeus/jdbc/util/Util.java
@@ -11,7 +11,7 @@
public class Util {
// utility functions
public static String formatNano(long l) {
- NumberFormat format = new DecimalFormat("###,##0.000000");
+ NumberFormat format = new DecimalFormat("###,##0.000");
return format.format((double) l / 1000000.0);
}
diff --git a/src/nl/astraeus/jdbc/web/page/QueryOverview.html b/src/nl/astraeus/jdbc/web/page/QueryOverview.html
index 6c435c5..8c62971 100644
--- a/src/nl/astraeus/jdbc/web/page/QueryOverview.html
+++ b/src/nl/astraeus/jdbc/web/page/QueryOverview.html
@@ -1,9 +1,14 @@
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Simple-jdbc-statistics.iml b/Simple-jdbc-statistics.iml
index ca90a9b..d61fca5 100644
--- a/Simple-jdbc-statistics.iml
+++ b/Simple-jdbc-statistics.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java
index c409b54..0d222e2 100644
--- a/src/nl/astraeus/jdbc/JdbcLogger.java
+++ b/src/nl/astraeus/jdbc/JdbcLogger.java
@@ -5,7 +5,6 @@
import org.slf4j.LoggerFactory;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
/**
* User: riennentjes
@@ -37,6 +36,17 @@
this.sql = sql;
this.milli = milli;
this.nano = nano;
+ this.count = 1;
+ }
+
+ public LogEntry(LogEntry le) {
+ this.timeStamp = System.currentTimeMillis();
+ this.hash = le.hash;
+ this.type = le.type;
+ this.sql = le .sql;
+ this.milli = le.milli;
+ this.nano = le.nano;
+ this.count = le.count;
}
public int getCount() {
@@ -64,11 +74,11 @@
}
public String getFormattedMilli() {
- return Util.formatNano(milli*1000000);
+ return Util.formatNano(milli*1000000/count);
}
public String getFormattedNano() {
- return Util.formatNano(nano);
+ return Util.formatNano(nano/count);
}
public String getTotal() {
@@ -78,6 +88,13 @@
public String getSql() {
return sql;
}
+
+ public void addCount(LogEntry le) {
+ count++;
+ this.milli += le.getMilli();
+ this.nano += le.getNano();
+ this.timeStamp = 0;
+ }
}
private final List queries;
diff --git a/src/nl/astraeus/jdbc/util/Util.java b/src/nl/astraeus/jdbc/util/Util.java
index eaa853b..44ce8c8 100644
--- a/src/nl/astraeus/jdbc/util/Util.java
+++ b/src/nl/astraeus/jdbc/util/Util.java
@@ -11,7 +11,7 @@
public class Util {
// utility functions
public static String formatNano(long l) {
- NumberFormat format = new DecimalFormat("###,##0.000000");
+ NumberFormat format = new DecimalFormat("###,##0.000");
return format.format((double) l / 1000000.0);
}
diff --git a/src/nl/astraeus/jdbc/web/page/QueryOverview.html b/src/nl/astraeus/jdbc/web/page/QueryOverview.html
index 6c435c5..8c62971 100644
--- a/src/nl/astraeus/jdbc/web/page/QueryOverview.html
+++ b/src/nl/astraeus/jdbc/web/page/QueryOverview.html
@@ -1,9 +1,14 @@
diff --git a/src/nl/astraeus/jdbc/web/page/QueryOverview.java b/src/nl/astraeus/jdbc/web/page/QueryOverview.java
index 589efa8..cd4cf62 100644
--- a/src/nl/astraeus/jdbc/web/page/QueryOverview.java
+++ b/src/nl/astraeus/jdbc/web/page/QueryOverview.java
@@ -43,12 +43,14 @@
Map result = new HashMap();
List entries = JdbcLogger.get().getEntries();
- Map duplicateCount = new HashMap();
long fromTime = System.currentTimeMillis();
long toTime = System.currentTimeMillis();
long avgTime = 0;
+ Map condensed = new HashMap();
+ List list;
+
if (!entries.isEmpty()) {
fromTime = entries.get(0).getTimeStamp();
toTime = entries.get(entries.size()-1).getTimeStamp();
@@ -58,30 +60,30 @@
for (JdbcLogger.LogEntry le : entries) {
total += le.getNano();
- Integer count = duplicateCount.get(le.getHash());
+ JdbcLogger.LogEntry entry = condensed.get(le.getHash());
- if (count == null) {
- count = 1;
+ if (entry == null) {
+ entry = new JdbcLogger.LogEntry(le);
+ condensed.put(entry.getHash(), entry);
} else {
- count++;
+ entry.addCount(le);
}
-
- duplicateCount.put(le.getHash(), count);
- le.setCount(count);
}
avgTime = total / entries.size();
}
+ list = new LinkedList(condensed.values());
+
if (sortTotalCalls) {
- Collections.sort(entries, new Comparator() {
+ Collections.sort(list, new Comparator() {
@Override
public int compare(JdbcLogger.LogEntry o1, JdbcLogger.LogEntry o2) {
return o2.getCount() - o1.getCount();
}
});
} else if (sortAvgTime) {
- Collections.sort(entries, new Comparator() {
+ Collections.sort(list, new Comparator() {
@Override
public int compare(JdbcLogger.LogEntry o1, JdbcLogger.LogEntry o2) {
long n1 = o1.getNano() / o1.getCount();
@@ -97,7 +99,7 @@
}
});
} else if (sortTotalTime) {
- Collections.sort(entries, new Comparator() {
+ Collections.sort(list, new Comparator() {
@Override
public int compare(JdbcLogger.LogEntry o1, JdbcLogger.LogEntry o2) {
if (o2.getNano() > o1.getNano()) {
@@ -111,7 +113,7 @@
});
}
- result.put("queries", entries);
+ result.put("queries", list);
result.put("count", entries.size());
result.put("sortTotalCalls", sortTotalCalls);
@@ -119,7 +121,7 @@
result.put("sortTotalTime", sortTotalTime);
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- DateFormat dateFormatter = new SimpleDateFormat("HH:ss:mm.SSS");
+ DateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.SSS");
result.put("fromTime", dateFormatter.format(new Date(fromTime)));
result.put("toTime", dateFormatter.format(new Date(toTime)));
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
deleted file mode 100644
index 07e0885..0000000
--- a/.idea/libraries/lib.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/lib1.xml b/.idea/libraries/lib1.xml
new file mode 100644
index 0000000..8ce9ba1
--- /dev/null
+++ b/.idea/libraries/lib1.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Simple-jdbc-statistics.iml b/Simple-jdbc-statistics.iml
index ca90a9b..d61fca5 100644
--- a/Simple-jdbc-statistics.iml
+++ b/Simple-jdbc-statistics.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/src/nl/astraeus/jdbc/JdbcLogger.java b/src/nl/astraeus/jdbc/JdbcLogger.java
index c409b54..0d222e2 100644
--- a/src/nl/astraeus/jdbc/JdbcLogger.java
+++ b/src/nl/astraeus/jdbc/JdbcLogger.java
@@ -5,7 +5,6 @@
import org.slf4j.LoggerFactory;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
/**
* User: riennentjes
@@ -37,6 +36,17 @@
this.sql = sql;
this.milli = milli;
this.nano = nano;
+ this.count = 1;
+ }
+
+ public LogEntry(LogEntry le) {
+ this.timeStamp = System.currentTimeMillis();
+ this.hash = le.hash;
+ this.type = le.type;
+ this.sql = le .sql;
+ this.milli = le.milli;
+ this.nano = le.nano;
+ this.count = le.count;
}
public int getCount() {
@@ -64,11 +74,11 @@
}
public String getFormattedMilli() {
- return Util.formatNano(milli*1000000);
+ return Util.formatNano(milli*1000000/count);
}
public String getFormattedNano() {
- return Util.formatNano(nano);
+ return Util.formatNano(nano/count);
}
public String getTotal() {
@@ -78,6 +88,13 @@
public String getSql() {
return sql;
}
+
+ public void addCount(LogEntry le) {
+ count++;
+ this.milli += le.getMilli();
+ this.nano += le.getNano();
+ this.timeStamp = 0;
+ }
}
private final List queries;
diff --git a/src/nl/astraeus/jdbc/util/Util.java b/src/nl/astraeus/jdbc/util/Util.java
index eaa853b..44ce8c8 100644
--- a/src/nl/astraeus/jdbc/util/Util.java
+++ b/src/nl/astraeus/jdbc/util/Util.java
@@ -11,7 +11,7 @@
public class Util {
// utility functions
public static String formatNano(long l) {
- NumberFormat format = new DecimalFormat("###,##0.000000");
+ NumberFormat format = new DecimalFormat("###,##0.000");
return format.format((double) l / 1000000.0);
}
diff --git a/src/nl/astraeus/jdbc/web/page/QueryOverview.html b/src/nl/astraeus/jdbc/web/page/QueryOverview.html
index 6c435c5..8c62971 100644
--- a/src/nl/astraeus/jdbc/web/page/QueryOverview.html
+++ b/src/nl/astraeus/jdbc/web/page/QueryOverview.html
@@ -1,9 +1,14 @@
diff --git a/src/nl/astraeus/jdbc/web/page/QueryOverview.java b/src/nl/astraeus/jdbc/web/page/QueryOverview.java
index 589efa8..cd4cf62 100644
--- a/src/nl/astraeus/jdbc/web/page/QueryOverview.java
+++ b/src/nl/astraeus/jdbc/web/page/QueryOverview.java
@@ -43,12 +43,14 @@
Map result = new HashMap();
List entries = JdbcLogger.get().getEntries();
- Map duplicateCount = new HashMap();
long fromTime = System.currentTimeMillis();
long toTime = System.currentTimeMillis();
long avgTime = 0;
+ Map condensed = new HashMap();
+ List list;
+
if (!entries.isEmpty()) {
fromTime = entries.get(0).getTimeStamp();
toTime = entries.get(entries.size()-1).getTimeStamp();
@@ -58,30 +60,30 @@
for (JdbcLogger.LogEntry le : entries) {
total += le.getNano();
- Integer count = duplicateCount.get(le.getHash());
+ JdbcLogger.LogEntry entry = condensed.get(le.getHash());
- if (count == null) {
- count = 1;
+ if (entry == null) {
+ entry = new JdbcLogger.LogEntry(le);
+ condensed.put(entry.getHash(), entry);
} else {
- count++;
+ entry.addCount(le);
}
-
- duplicateCount.put(le.getHash(), count);
- le.setCount(count);
}
avgTime = total / entries.size();
}
+ list = new LinkedList(condensed.values());
+
if (sortTotalCalls) {
- Collections.sort(entries, new Comparator() {
+ Collections.sort(list, new Comparator() {
@Override
public int compare(JdbcLogger.LogEntry o1, JdbcLogger.LogEntry o2) {
return o2.getCount() - o1.getCount();
}
});
} else if (sortAvgTime) {
- Collections.sort(entries, new Comparator() {
+ Collections.sort(list, new Comparator() {
@Override
public int compare(JdbcLogger.LogEntry o1, JdbcLogger.LogEntry o2) {
long n1 = o1.getNano() / o1.getCount();
@@ -97,7 +99,7 @@
}
});
} else if (sortTotalTime) {
- Collections.sort(entries, new Comparator() {
+ Collections.sort(list, new Comparator() {
@Override
public int compare(JdbcLogger.LogEntry o1, JdbcLogger.LogEntry o2) {
if (o2.getNano() > o1.getNano()) {
@@ -111,7 +113,7 @@
});
}
- result.put("queries", entries);
+ result.put("queries", list);
result.put("count", entries.size());
result.put("sortTotalCalls", sortTotalCalls);
@@ -119,7 +121,7 @@
result.put("sortTotalTime", sortTotalTime);
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- DateFormat dateFormatter = new SimpleDateFormat("HH:ss:mm.SSS");
+ DateFormat dateFormatter = new SimpleDateFormat("HH:mm:ss.SSS");
result.put("fromTime", dateFormatter.format(new Date(fromTime)));
result.put("toTime", dateFormatter.format(new Date(toTime)));
diff --git a/test/dummy.txt b/test/dummy.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/dummy.txt