From e5252fd5b21530615b6b8510cb81b83df34ee482 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Tue, 12 Aug 2008 20:34:26 -0700
Subject: [PATCH] web/deep-check: show the webapi runtime at the bottom of the
 page

---
 src/allmydata/web/checker_results.py       | 6 ++++++
 src/allmydata/web/deep-check-results.xhtml | 2 ++
 src/allmydata/webish.py                    | 2 ++
 3 files changed, 10 insertions(+)

diff --git a/src/allmydata/web/checker_results.py b/src/allmydata/web/checker_results.py
index 532ed236..370605fa 100644
--- a/src/allmydata/web/checker_results.py
+++ b/src/allmydata/web/checker_results.py
@@ -1,4 +1,5 @@
 
+import time
 from nevow import rend, inevow, tags as T
 from allmydata.web.common import getxmlfile, get_arg
 from allmydata.interfaces import ICheckerResults, IDeepCheckResults
@@ -72,3 +73,8 @@ class DeepCheckResults(rend.Page):
         if return_to:
             return T.div[T.a(href=return_to)["Return to parent directory"]]
         return ""
+
+    def render_runtime(self, ctx, data):
+        req = inevow.IRequest(ctx)
+        runtime = time.time() - req.processing_started_timestamp
+        return ctx.tag["runtime: %s seconds" % runtime]
diff --git a/src/allmydata/web/deep-check-results.xhtml b/src/allmydata/web/deep-check-results.xhtml
index 2f819808..d4b040bc 100644
--- a/src/allmydata/web/deep-check-results.xhtml
+++ b/src/allmydata/web/deep-check-results.xhtml
@@ -48,5 +48,7 @@
 
 <div n:render="return" />
 
+<div n:render="runtime" />
+
   </body>
 </html>
diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py
index 6e7e9316..ed7173d1 100644
--- a/src/allmydata/webish.py
+++ b/src/allmydata/webish.py
@@ -1,4 +1,5 @@
 
+import time
 from twisted.application import service, strports, internet
 from twisted.web import http
 from twisted.internet import defer
@@ -75,6 +76,7 @@ class MyRequest(appserver.NevowRequest):
 ##                      self.channel.transport.loseConnection()
 ##                      return
 ##                  raise
+        self.processing_started_timestamp = time.time()
         self.process()
 
     def _logger(self):
-- 
2.45.2