changeset 1338:bbfc3f305c6b beta

Updated test_crawler to scan paths in more sensible order using ordered tuple.
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 15 May 2011 18:20:53 +0200
parents 37625d304a16
children e861eb1c4a2f
files rhodecode/tests/test_crawler.py
diffstat 1 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/tests/test_crawler.py	Sun May 15 18:18:00 2011 +0200
+++ b/rhodecode/tests/test_crawler.py	Sun May 15 18:20:53 2011 +0200
@@ -70,15 +70,17 @@
     print 'average on req', total_time / float(pages)
 
 
-def test_changeset_walk():
-    print jn(PROJECT_PATH, PROJECT)
+def test_changeset_walk(limit=None):
+    print 'processing', jn(PROJECT_PATH, PROJECT)
     total_time = 0
 
     repo = vcs.get_repo(jn(PROJECT_PATH, PROJECT))
-
+    cnt = 0
     for i in repo:
-
+        cnt += 1
         raw_cs = '/'.join((PROJECT, 'changeset', i.raw_id))
+        if limit and limit == cnt:
+            break
 
         full_uri = (BASE_URI % raw_cs)
         s = time.time()
@@ -89,23 +91,29 @@
         print 'visited %s\%s size:%s req:%s ms' % (full_uri, i, size, e)
 
     print 'total_time', total_time
-    print 'average on req', total_time / float(len(repo))
+    print 'average on req', total_time / float(cnt)
+
 
 def test_files_walk():
-    print jn(PROJECT_PATH, PROJECT)
+    print 'processing', jn(PROJECT_PATH, PROJECT)
     total_time = 0
 
     repo = vcs.get_repo(jn(PROJECT_PATH, PROJECT))
 
-    paths_ = set()
+    from rhodecode.lib.oset import OrderedSet
+
+    paths_ = OrderedSet([''])
     try:
         tip = repo.get_changeset('tip')
         for topnode, dirs, files in tip.walk('/'):
+
+            for dir in dirs:
+                paths_.add(dir.path)
+                for f in dir:
+                    paths_.add(f.path)
+
             for f in files:
                 paths_.add(f.path)
-            for dir in dirs:
-                for f in files:
-                    paths_.add(f.path)
 
     except vcs.exception.RepositoryError, e:
         pass
@@ -125,6 +133,7 @@
     print 'average on req', total_time / float(len(repo))
 
 
-#test_changelog_walk()
-#test_changeset_walk()
 test_files_walk()
+test_changelog_walk(40)
+test_changeset_walk(limit=100)
+