##// END OF EJS Templates
tests: updated load tests CLIs
marcink -
r3811:0c0d4d8c stable
parent child Browse files
Show More
@@ -0,0 +1,2 b''
1 big/CPython
2 big/CPython/commits
@@ -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",
33
31 "cpython/files/tip/",
34 print("Repeating each URL %d times\n" % repeat)
32 "cpython/files/74236c8bf064188516b32bf95016971227ec72a9/Grammar",
35 pages = pages.readlines()
33 "",
36
34 "git",
37 for page_url in pages:
35 "git/annotate/6c4ab27f2378ce67940b4496365043119d7ffff2/gitk-git/.gitignore",
38
36 "git/changelog",
39 url = "%s/%s" % (server, page_url.strip())
37 "git/changeset/d299e9e550c1bf8640907fdba1f03cc585ee71df",
40 print(url)
38 "git/compare/rev@1200...rev@1300?target_repo=git",
41
39 "git/files/tip/",
42 stmt = "requests.get('%s', timeout=120)" % url
40 "git/files/6c4ab27f2378ce67940b4496365043119d7ffff2/.gitignore"
43 t = timeit.Timer(stmt=stmt, setup="import requests")
41 ]
42
44
43 svn_pages = [
45 result = t.repeat(repeat=repeat, number=1)
44 "svn-apache",
46 print(" %.3f (min) - %.3f (max) - %.3f (avg)\n" %
45 "svn-apache/annotate/672129/cocoon/trunk/README.txt",
47 (min(result), max(result), sum(result) / len(result)))
46 "svn-apache/changelog",
48
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
49
54 # Uncomment to check also svn performance
50 if __name__ == '__main__':
55 # pages = pages + svn_pages
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)
63
60 for page in pages:
64
61 url = "http://%s/%s" % (server, page)
65
62 print(url)
63
66
64 stmt = "urllib2.urlopen('%s', timeout=120)" % url
67
65 t = timeit.Timer(stmt=stmt, setup="import urllib2")
68
69
66
70
67 result = t.repeat(repeat=repeat, number=1)
71
68 print("\t%.3f (min) - %.3f (max) - %.3f (avg)\n" %
72
69 (min(result), max(result), sum(result)/len(result)))
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