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