[Bedework-commit] calendarapi r735 - releases/bedework-3.4.1.1a/calCore/src/org/bedework/calcore/hibernate

svnadmin at bedework.org svnadmin at bedework.org
Wed Nov 12 23:28:17 EST 2008


Author: douglm
Date: 2008-11-12 23:28:08 -0500 (Wed, 12 Nov 2008)
New Revision: 735

Modified:
   releases/bedework-3.4.1.1a/calCore/src/org/bedework/calcore/hibernate/DbStatistics.java
Log:
Display more statistics

Modified: releases/bedework-3.4.1.1a/calCore/src/org/bedework/calcore/hibernate/DbStatistics.java
===================================================================
--- releases/bedework-3.4.1.1a/calCore/src/org/bedework/calcore/hibernate/DbStatistics.java	2008-11-13 04:23:01 UTC (rev 734)
+++ releases/bedework-3.4.1.1a/calCore/src/org/bedework/calcore/hibernate/DbStatistics.java	2008-11-13 04:28:08 UTC (rev 735)
@@ -1,33 +1,5 @@
-/*
- Copyright (c) 2000-2005 University of Washington.  All rights reserved.
-
- Redistribution and use of this distribution in source and binary forms,
- with or without modification, are permitted provided that:
-
-   The above copyright notice and this permission notice appear in
-   all copies and supporting documentation;
-
-   The name, identifiers, and trademarks of the University of Washington
-   are not used in advertising or publicity without the express prior
-   written permission of the University of Washington;
-
-   Recipients acknowledge that this distribution is made available as a
-   research courtesy, "as is", potentially with defects, without
-   any obligation on the part of the University of Washington to
-   provide support, services, or repair;
-
-   THE UNIVERSITY OF WASHINGTON DISCLAIMS ALL WARRANTIES, EXPRESS OR
-   IMPLIED, WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT LIMITATION
-   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-   PARTICULAR PURPOSE, AND IN NO EVENT SHALL THE UNIVERSITY OF
-   WASHINGTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-   DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-   PROFITS, WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING
-   NEGLIGENCE) OR STRICT LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
-   THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
 /* **********************************************************************
-    Copyright 2005 Rensselaer Polytechnic Institute. All worldwide rights reserved.
+    Copyright 2008 Rensselaer Polytechnic Institute. All worldwide rights reserved.
 
     Redistribution and use of this distribution in source and binary forms,
     with or without modification, are permitted provided that:
@@ -58,6 +30,7 @@
 
 import org.bedework.calfacade.BwCalendar;
 import org.bedework.calfacade.BwCategory;
+import org.bedework.calfacade.BwEventAnnotation;
 import org.bedework.calfacade.BwEventObj;
 import org.bedework.calfacade.BwLocation;
 import org.bedework.calfacade.BwContact;
@@ -69,12 +42,13 @@
 
 import org.hibernate.stat.CollectionStatistics;
 import org.hibernate.stat.EntityStatistics;
+import org.hibernate.stat.QueryStatistics;
 import org.hibernate.stat.SecondLevelCacheStatistics;
 import org.hibernate.stat.Statistics;
 
 /** Class to help display statistics.
  *
- * @author Mike Douglass   douglm at rpi.edu
+ * @author Mike Douglass
  */
 public class DbStatistics {
   /** Dump the statistics to the log
@@ -106,6 +80,8 @@
       return al;
     }
 
+    al.add(new StatsEntry("Database statistics"));
+
     al.add(new StatsEntry("Number of connection requests", dbStats.getConnectCount()));
     al.add(new StatsEntry("Session flushes", dbStats.getFlushCount()));
     al.add(new StatsEntry("Transactions", dbStats.getTransactionCount()));
@@ -113,7 +89,8 @@
     al.add(new StatsEntry("Sessions opened", dbStats.getSessionOpenCount()));
     al.add(new StatsEntry("Sessions closed", dbStats.getSessionCloseCount()));
     al.add(new StatsEntry("Queries executed", dbStats.getQueryExecutionCount()));
-    al.add(new StatsEntry("Slowest query time", dbStats.getQueryExecutionMaxTime()));
+    al.add(new StatsEntry("Max query time", dbStats.getQueryExecutionMaxTime()));
+    al.add(new StatsEntry("Max time query", dbStats.getQueryExecutionMaxTimeQueryString()));
 
     al.add(new StatsEntry("Collection statistics"));
 
@@ -141,20 +118,45 @@
     al.add(new StatsEntry("Cache hit ratio", chit / (chit + cmiss)));
 
     entityStats(al, dbStats, BwCalendar.class);
+    entityStats(al, dbStats, BwEventObj.class);
+    entityStats(al, dbStats, BwEventAnnotation.class);
     entityStats(al, dbStats, BwCategory.class);
-    entityStats(al, dbStats, BwEventObj.class);
     entityStats(al, dbStats, BwLocation.class);
     entityStats(al, dbStats, BwContact.class);
     entityStats(al, dbStats, BwUser.class);
 
     collectionStats(al, dbStats, BwCalendar.class, "children");
+
+    collectionStats(al, dbStats, BwEventObj.class, "attendees");
     collectionStats(al, dbStats, BwEventObj.class, "categories");
-    collectionStats(al, dbStats, BwEventObj.class, "attendees");
+    collectionStats(al, dbStats, BwEventObj.class, "descriptions");
+    collectionStats(al, dbStats, BwEventObj.class, "summaries");
+
     collectionStats(al, dbStats, BwEventObj.class, "rrules");
-    //collectionStats(v, dbStats, BwEventObj.class, "exrules");
     collectionStats(al, dbStats, BwEventObj.class, "rdates");
     collectionStats(al, dbStats, BwEventObj.class, "exdates");
 
+    collectionStats(al, dbStats, BwEventAnnotation.class, "attendees");
+    collectionStats(al, dbStats, BwEventAnnotation.class, "categories");
+    collectionStats(al, dbStats, BwEventAnnotation.class, "descriptions");
+    collectionStats(al, dbStats, BwEventAnnotation.class, "summaries");
+
+    collectionStats(al, dbStats, BwEventAnnotation.class, "rrules");
+    collectionStats(al, dbStats, BwEventAnnotation.class, "rdates");
+    collectionStats(al, dbStats, BwEventAnnotation.class, "exdates");
+
+    String[] qs = dbStats.getQueries();
+
+    for (String q: qs) {
+      queryStats(al, dbStats, q);
+    }
+
+    String[] slcrn = dbStats.getSecondLevelCacheRegionNames();
+
+    for (String s: slcrn) {
+      secondLevelStats(al, dbStats, s);
+    }
+
     return al;
   }
 
@@ -189,7 +191,23 @@
     c.add(new StatsEntry("Updated", cStats.getUpdateCount()));
   }
 
-  @SuppressWarnings("unused")
+  private static void queryStats(Collection<StatsEntry> c,
+                                 Statistics dbStats,
+                                 String q) {
+    c.add(new StatsEntry("Query statistics for " + q));
+
+    QueryStatistics qStats = dbStats.getQueryStatistics(q);
+
+    c.add(new StatsEntry("Execution ct", qStats.getExecutionCount()));
+    c.add(new StatsEntry("Cache hits", qStats.getCacheHitCount()));
+    c.add(new StatsEntry("Cache puts", qStats.getCachePutCount()));
+    c.add(new StatsEntry("Cache misses", qStats.getCacheMissCount()));
+    c.add(new StatsEntry("Execution row ct", qStats.getExecutionRowCount()));
+    c.add(new StatsEntry("Execution avg millis", qStats.getExecutionAvgTime()));
+    c.add(new StatsEntry("Execution max millis", qStats.getExecutionMaxTime()));
+    c.add(new StatsEntry("Execution min millis", qStats.getExecutionMinTime()));
+  }
+
   private static void secondLevelStats(Collection<StatsEntry> c,
                                        Statistics dbStats,
                                        String name) {



More information about the Bedework-commit mailing list