Add measurement of execution time for servlets
[jabaws.git] / webservices / compbio / stat / servlet / AnnualStat.java
index 3ec55ce..26150de 100644 (file)
@@ -40,6 +40,7 @@ public class AnnualStat extends HttpServlet {
                        throws ServletException, IOException {\r
 \r
                try {\r
+                       long startTime = System.nanoTime();\r
                        StatDB db = new StatDB();\r
                        Date earliestRec = db.getEarliestRecord();\r
                        if (earliestRec == null) {\r
@@ -50,13 +51,13 @@ public class AnnualStat extends HttpServlet {
                                writer.close();\r
                                return;\r
                        }\r
-                       Map<Date, Totals> monthlyTotals = StatCollection\r
-                                       .getStats(earliestRec);\r
+                       Map<Date, Totals> monthlyTotals = StatCollection.getStats(earliestRec);\r
+                       long endTime = System.nanoTime();\r
                        req.setAttribute("stat", monthlyTotals);\r
                        req.setAttribute("total", Totals.sumOfTotals(monthlyTotals));\r
+                       req.setAttribute("timeexec", (endTime - startTime) / 1000000);\r
 \r
-                       RequestDispatcher dispatcher = req\r
-                                       .getRequestDispatcher("statpages/MonthlySummary.jsp");\r
+                       RequestDispatcher dispatcher = req.getRequestDispatcher("statpages/MonthlySummary.jsp");\r
 \r
                        req.setAttribute("isAdmin", isAdmin(req));\r
                        dispatcher.forward(req, resp);\r