##// END OF EJS Templates
improvements for rhodecode crawler
marcink -
r2226:ce04e6ef beta
parent child Browse files
Show More
@@ -42,8 +42,22 b' from os.path import dirname as dn'
42 sys.path.append(__root__)
42 sys.path.append(__root__)
43
43
44 from rhodecode.lib import vcs
44 from rhodecode.lib import vcs
45 from rhodecode.lib.compat import OrderedSet
46 from rhodecode.lib.vcs.exceptions import RepositoryError
45
47
46 BASE_URI = 'http://127.0.0.1:5001/%s'
48 PASES = 3
49 HOST = 'http://127.0.0.1'
50 PORT = 5000
51 BASE_URI = '%s:%s/' % (HOST, PORT)
52
53 if len(sys.argv) == 2:
54 BASE_URI = sys.argv[1]
55
56 if not BASE_URI.endswith('/'):
57 BASE_URI += '/'
58
59 print 'Crawling @ %s' % BASE_URI
60 BASE_URI += '%s'
47 PROJECT_PATH = jn('/', 'home', 'marcink', 'hg_repos')
61 PROJECT_PATH = jn('/', 'home', 'marcink', 'hg_repos')
48 PROJECTS = [
62 PROJECTS = [
49 'linux-magx-pbranch',
63 'linux-magx-pbranch',
@@ -62,7 +76,20 b' o.addheaders = ['
62 urllib2.install_opener(o)
76 urllib2.install_opener(o)
63
77
64
78
79 def _get_repo(proj):
80 if isinstance(proj, basestring):
81 repo = vcs.get_repo(jn(PROJECT_PATH, proj))
82 proj = proj
83 else:
84 repo = proj
85 proj = repo.name
86
87 return repo, proj
88
89
65 def test_changelog_walk(proj, pages=100):
90 def test_changelog_walk(proj, pages=100):
91 repo, proj = _get_repo(proj)
92
66 total_time = 0
93 total_time = 0
67 for i in range(1, pages):
94 for i in range(1, pages):
68
95
@@ -81,10 +108,11 b' def test_changelog_walk(proj, pages=100)'
81
108
82
109
83 def test_changeset_walk(proj, limit=None):
110 def test_changeset_walk(proj, limit=None):
111 repo, proj = _get_repo(proj)
112
84 print 'processing', jn(PROJECT_PATH, proj)
113 print 'processing', jn(PROJECT_PATH, proj)
85 total_time = 0
114 total_time = 0
86
115
87 repo = vcs.get_repo(jn(PROJECT_PATH, proj))
88 cnt = 0
116 cnt = 0
89 for i in repo:
117 for i in repo:
90 cnt += 1
118 cnt += 1
@@ -106,14 +134,11 b' def test_changeset_walk(proj, limit=None'
106
134
107
135
108 def test_files_walk(proj, limit=100):
136 def test_files_walk(proj, limit=100):
137 repo, proj = _get_repo(proj)
138
109 print 'processing', jn(PROJECT_PATH, proj)
139 print 'processing', jn(PROJECT_PATH, proj)
110 total_time = 0
140 total_time = 0
111
141
112 repo = vcs.get_repo(jn(PROJECT_PATH, proj))
113
114 from rhodecode.lib.compat import OrderedSet
115 from rhodecode.lib.vcs.exceptions import RepositoryError
116
117 paths_ = OrderedSet([''])
142 paths_ = OrderedSet([''])
118 try:
143 try:
119 tip = repo.get_changeset('tip')
144 tip = repo.get_changeset('tip')
@@ -150,10 +175,10 b' def test_files_walk(proj, limit=100):'
150 print 'average on req', total_time / float(cnt)
175 print 'average on req', total_time / float(cnt)
151
176
152 if __name__ == '__main__':
177 if __name__ == '__main__':
153
178 for path in PROJECTS:
154 for p in PROJECTS:
179 repo = vcs.get_repo(jn(PROJECT_PATH, path))
155 test_changelog_walk(p, 40)
180 for i in range(PASES):
156 time.sleep(2)
181 print 'PASS %s/%s' % (i, PASES)
157 test_changeset_walk(p, limit=100)
182 test_changelog_walk(repo, pages=80)
158 time.sleep(2)
183 test_changeset_walk(repo, limit=100)
159 test_files_walk(p, 100)
184 test_files_walk(repo, limit=100)
General Comments 0
You need to be logged in to leave comments. Login now