allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [2/4] git commit: [#4832] Add more SCM timing instrumentation.
Date Tue, 29 Jan 2013 19:13:28 GMT
[#4832] Add more SCM timing instrumentation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/9d73ea7f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/9d73ea7f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/9d73ea7f

Branch: refs/heads/master
Commit: 9d73ea7f6e58742a8815b86f391e8df6f150bcc7
Parents: 9f6448e
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Tue Jan 29 16:12:33 2013 +0000
Committer: Dave Brondsema <dbrondsema@geek.net>
Committed: Tue Jan 29 19:13:15 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/custom_middleware.py |   36 ++++++++++++++++++++++++---
 ForgeSVN/forgesvn/model/svn.py         |   32 +++++++++++++++++++++++-
 requirements-common.txt                |    2 +-
 3 files changed, 64 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d73ea7f/Allura/allura/lib/custom_middleware.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index e6a1d68..3be5eec 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -149,16 +149,24 @@ class SSLMiddleware(object):
 
 class AlluraTimerMiddleware(TimerMiddleware):
     def timers(self):
+        import allura
+        import forgesvn
         import genshi
+        import git
         import jinja2
         import markdown
+        import mercurial
         import ming
         import pymongo
         import socket
         import urllib2
 
-        return [
+        return self.repo_impl_timers() + [
+            Timer('git', git.Repo, 'rev_parse', 'iter_commits', 'commit'),
+            Timer('jinja', jinja2.Template, 'render', 'stream', 'generate'),
             Timer('markdown', markdown.Markdown, 'convert'),
+            Timer('hg', mercurial.hg.localrepo.localrepository, 'heads',
+                'branchtags', 'tags'),
             Timer('ming', ming.odm.odmsession.ODMCursor, 'next'),
             Timer('ming', ming.odm.odmsession.ODMSession, 'flush', 'find',
                 'get'),
@@ -172,20 +180,40 @@ class AlluraTimerMiddleware(TimerMiddleware):
             Timer('mongo', pymongo.cursor.Cursor, 'count', 'distinct',
                 'explain', 'hint', 'limit', 'next', 'rewind', 'skip',
                 'sort', 'where'),
-            Timer('jinja', jinja2.Template, 'render', 'stream', 'generate'),
+            Timer('svn', forgesvn.model.svn.SVNLibWrapper, 'checkout', 'add',
+                'checkin', 'info2', 'log', 'cat', 'list'),
             # urlopen and socket io may or may not overlap partially
-            Timer('urlopen', urllib2, 'urlopen'),
             Timer('render', genshi.Stream, 'render'),
+            Timer('sidebar', allura.app.Application, 'sidebar_menu'),
             Timer('socket_read', socket._fileobject, 'read', 'readline',
                 'readlines', debug_each_call=False),
             Timer('socket_write', socket._fileobject, 'write', 'writelines',
                 'flush', debug_each_call=False),
+            Timer('solr', pysolr.Solr, 'add', 'delete', 'search', 'commit'),
             Timer('template', genshi.template.Template, '_prepare', '_parse',
                 'generate'),
-            Timer('solr', pysolr.Solr, 'add', 'delete', 'search', 'commit'),
+            Timer('urlopen', urllib2, 'urlopen'),
         ]
 
     def before_logging(self, stat_record):
         if hasattr(c, "app") and hasattr(c.app, "config"):
             stat_record.add('request_category', c.app.config.tool_name.lower())
         return stat_record
+
+    def repo_impl_timers(self):
+        from forgegit.model.git_repo import GitImplementation
+        from forgesvn.model.svn import SVNImplementation
+
+        repo_impl_timers = [
+            Timer('git_impl', GitImplementation, '*'),
+            Timer('svn_impl', SVNImplementation, '*'),
+        ]
+
+        try:
+            from forgehg.model.hg import HgImplementation
+            repo_impl_timers.append(
+                    Timer('hg_impl', HgImplementation, '*'))
+        except ImportError:
+            pass
+
+        return repo_impl_timers

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d73ea7f/ForgeSVN/forgesvn/model/svn.py
----------------------------------------------------------------------
diff --git a/ForgeSVN/forgesvn/model/svn.py b/ForgeSVN/forgesvn/model/svn.py
index 4228b50..f781d6c 100644
--- a/ForgeSVN/forgesvn/model/svn.py
+++ b/ForgeSVN/forgesvn/model/svn.py
@@ -96,6 +96,36 @@ class SVNCalledProcessError(Exception):
             (self.cmd, self.returncode, self.stdout, self.stderr)
 
 
+class SVNLibWrapper(object):
+    """Wrapper around pysvn, used for instrumentation."""
+    def __init__(self, client):
+        self.client = client
+
+    def checkout(self, *args, **kw):
+        return self.client.checkout(*args, **kw)
+
+    def add(self, *args, **kw):
+        return self.client.add(*args, **kw)
+
+    def checkin(self, *args, **kw):
+        return self.client.checkin(*args, **kw)
+
+    def info2(self, *args, **kw):
+        return self.client.info2(*args, **kw)
+
+    def log(self, *args, **kw):
+        return self.client.log(*args, **kw)
+
+    def cat(self, *args, **kw):
+        return self.client.cat(*args, **kw)
+
+    def list(self, *args, **kw):
+        return self.client.list(*args, **kw)
+
+    def __getattr__(self, name):
+        return getattr(self.client, name)
+
+
 class SVNImplementation(M.RepositoryImplementation):
     post_receive_template = string.Template(
         '#!/bin/bash\n'
@@ -113,7 +143,7 @@ class SVNImplementation(M.RepositoryImplementation):
 
     @LazyProperty
     def _svn(self):
-        return pysvn.Client()
+        return SVNLibWrapper(pysvn.Client())
 
     @LazyProperty
     def _url(self):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/9d73ea7f/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 2750ec0..d19130b 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -42,7 +42,7 @@ pytidylib==0.2.1
 textile==2.1.5
 # dep of colander
 translationstring==0.4
-TimerMiddleware==0.4
+TimerMiddleware==0.4.1
 TurboGears2==2.1.5
 WebOb==1.0.8
 # part of the stdlib, but with a version number.  see http://guide.python-distribute.org/pip.html#listing-installed-packages


Mime
View raw message