Show More
@@ -19,51 +19,55 b'' | |||
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import timeit |
|
22 | import logging | |
|
23 | import click | |
|
22 | 24 | |
|
23 | server = "localhost:5000" | |
|
25 | log = logging.getLogger(__name__) | |
|
26 | ||
|
24 | 27 | |
|
25 | pages = [ | |
|
26 | "cpython", | |
|
27 | "cpython/annotate/74236c8bf064188516b32bf95016971227ec72a9/Makefile.pre.in", | |
|
28 | "cpython/changelog", | |
|
29 | "cpython/changeset/e0f681f4ade3af52915d5f32daac97ada580d71a", | |
|
30 | "cpython/compare/tag@v3.4.1rc1...tag@v3.4.1?target_repo=cpython", | |
|
31 | "cpython/files/tip/", | |
|
32 | "cpython/files/74236c8bf064188516b32bf95016971227ec72a9/Grammar", | |
|
33 | "", | |
|
34 | "git", | |
|
35 | "git/annotate/6c4ab27f2378ce67940b4496365043119d7ffff2/gitk-git/.gitignore", | |
|
36 | "git/changelog", | |
|
37 | "git/changeset/d299e9e550c1bf8640907fdba1f03cc585ee71df", | |
|
38 | "git/compare/rev@1200...rev@1300?target_repo=git", | |
|
39 | "git/files/tip/", | |
|
40 | "git/files/6c4ab27f2378ce67940b4496365043119d7ffff2/.gitignore" | |
|
41 | ] | |
|
28 | @click.command() | |
|
29 | @click.option('--server', help='Server url to connect to. e.g http://rc.local.com', required=True) | |
|
30 | @click.option('--pages', help='load pages to visit from a file', required=True, type=click.File()) | |
|
31 | @click.option('--repeat', help='number of times to repeat', default=10, type=int) | |
|
32 | def main(server, repeat, pages): | |
|
33 | ||
|
34 | print("Repeating each URL %d times\n" % repeat) | |
|
35 | pages = pages.readlines() | |
|
36 | ||
|
37 | for page_url in pages: | |
|
38 | ||
|
39 | url = "%s/%s" % (server, page_url.strip()) | |
|
40 | print(url) | |
|
41 | ||
|
42 | stmt = "requests.get('%s', timeout=120)" % url | |
|
43 | t = timeit.Timer(stmt=stmt, setup="import requests") | |
|
42 | 44 | |
|
43 | svn_pages = [ | |
|
44 | "svn-apache", | |
|
45 | "svn-apache/annotate/672129/cocoon/trunk/README.txt", | |
|
46 | "svn-apache/changelog", | |
|
47 | "svn-apache/changeset/1164362", | |
|
48 | "svn-apache/compare/rev@1164350...rev@1164360?target_repo=svn-apache", | |
|
49 | "svn-apache/compare/rev@1164300...rev@1164360?target_repo=svn-apache", | |
|
50 | "svn-apache/files/tip/", | |
|
51 | "svn-apache/files/1164363/cocoon/trunk/README.txt", | |
|
52 | ] | |
|
45 | result = t.repeat(repeat=repeat, number=1) | |
|
46 | print(" %.3f (min) - %.3f (max) - %.3f (avg)\n" % | |
|
47 | (min(result), max(result), sum(result) / len(result))) | |
|
48 | ||
|
53 | 49 | |
|
54 | # Uncomment to check also svn performance | |
|
55 | # pages = pages + svn_pages | |
|
50 | if __name__ == '__main__': | |
|
51 | main() | |
|
52 | ||
|
53 | ||
|
54 | ||
|
55 | ||
|
56 | ||
|
57 | ||
|
58 | ||
|
56 | 59 | |
|
57 | repeat = 10 | |
|
60 | ||
|
61 | ||
|
58 | 62 | |
|
59 | print("Repeating each URL x%d\n" % repeat) | |
|
60 | for page in pages: | |
|
61 | url = "http://%s/%s" % (server, page) | |
|
62 | print(url) | |
|
63 | ||
|
64 | ||
|
65 | ||
|
63 | 66 | |
|
64 | stmt = "urllib2.urlopen('%s', timeout=120)" % url | |
|
65 | t = timeit.Timer(stmt=stmt, setup="import urllib2") | |
|
67 | ||
|
68 | ||
|
69 | ||
|
66 | 70 | |
|
67 | result = t.repeat(repeat=repeat, number=1) | |
|
68 | print("\t%.3f (min) - %.3f (max) - %.3f (avg)\n" % | |
|
69 | (min(result), max(result), sum(result)/len(result))) | |
|
71 | ||
|
72 | ||
|
73 |
@@ -108,12 +108,12 b' class Repository(object):' | |||
|
108 | 108 | self.name = name |
|
109 | 109 | self.path = os.path.join(base_path, name) |
|
110 | 110 | self.api = api |
|
111 | self.url = None | |
|
111 | 112 | |
|
112 | 113 | def create(self): |
|
113 | 114 | self._create_filesystem_repo(self.path) |
|
114 | 115 | try: |
|
115 | self.url = self.api.create_repo( | |
|
116 | self.name, self.TYPE, 'Performance tests') | |
|
116 | self.url = self.api.create_repo(self.name, self.TYPE, 'Performance tests') | |
|
117 | 117 | except ApiError as e: |
|
118 | 118 | log.error('api: {}'.format(e)) |
|
119 | 119 | |
@@ -127,7 +127,7 b' class Repository(object):' | |||
|
127 | 127 | def create_commits(self, number, file_size): |
|
128 | 128 | for i in xrange(number): |
|
129 | 129 | file_name = self.FILE_NAME_TEMPLATE.format(i) |
|
130 | log.debug("Create commit {}".format(file_name)) | |
|
130 | log.debug("Create commit[{}] {}".format(self.name, file_name)) | |
|
131 | 131 | self._create_file(file_name, file_size) |
|
132 | 132 | self._create_commit(file_name) |
|
133 | 133 | |
@@ -258,8 +258,8 b' class Benchmark(object):' | |||
|
258 | 258 | for operation in operations: |
|
259 | 259 | for type_ in repos: |
|
260 | 260 | times = self._measure(repos[type_], *operation) |
|
261 | print("Mean {} {} time: {:.3f} sec.".format( | |
|
262 | type_, operation[0], mean(times))) | |
|
261 | print("Mean[of {}] {:5s} {:5s} time: {:.3f} sec.".format( | |
|
262 | len(times), type_, operation[0], mean(times))) | |
|
263 | 263 | |
|
264 | 264 | def cleanup(self): |
|
265 | 265 | log.info("Cleaning up...") |
@@ -296,6 +296,7 b' class Benchmark(object):' | |||
|
296 | 296 | log.addHandler(handler) |
|
297 | 297 | log.setLevel(log_level) |
|
298 | 298 | |
|
299 | ||
|
299 | 300 | if __name__ == '__main__': |
|
300 | 301 | config = Config() |
|
301 | 302 | benchmark = Benchmark(config) |
General Comments 0
You need to be logged in to leave comments.
Login now