tests: updated load tests CLIs

This commit is contained in:
Marcin Kuzminski 2019-07-09 15:53:44 +02:00
parent 7e6bc58c63
commit 87714d17c1
3 changed files with 52 additions and 45 deletions

View file

@ -0,0 +1,2 @@
big/CPython
big/CPython/commits

View file

@ -19,51 +19,55 @@
# and proprietary license terms, please see https://rhodecode.com/licenses/
import timeit
import logging
import click
log = logging.getLogger(__name__)
@click.command()
@click.option('--server', help='Server url to connect to. e.g http://rc.local.com', required=True)
@click.option('--pages', help='load pages to visit from a file', required=True, type=click.File())
@click.option('--repeat', help='number of times to repeat', default=10, type=int)
def main(server, repeat, pages):
print("Repeating each URL %d times\n" % repeat)
pages = pages.readlines()
for page_url in pages:
url = "%s/%s" % (server, page_url.strip())
print(url)
stmt = "requests.get('%s', timeout=120)" % url
t = timeit.Timer(stmt=stmt, setup="import requests")
result = t.repeat(repeat=repeat, number=1)
print(" %.3f (min) - %.3f (max) - %.3f (avg)\n" %
(min(result), max(result), sum(result) / len(result)))
if __name__ == '__main__':
main()
server = "localhost:5000"
pages = [
"cpython",
"cpython/annotate/74236c8bf064188516b32bf95016971227ec72a9/Makefile.pre.in",
"cpython/changelog",
"cpython/changeset/e0f681f4ade3af52915d5f32daac97ada580d71a",
"cpython/compare/tag@v3.4.1rc1...tag@v3.4.1?target_repo=cpython",
"cpython/files/tip/",
"cpython/files/74236c8bf064188516b32bf95016971227ec72a9/Grammar",
"",
"git",
"git/annotate/6c4ab27f2378ce67940b4496365043119d7ffff2/gitk-git/.gitignore",
"git/changelog",
"git/changeset/d299e9e550c1bf8640907fdba1f03cc585ee71df",
"git/compare/rev@1200...rev@1300?target_repo=git",
"git/files/tip/",
"git/files/6c4ab27f2378ce67940b4496365043119d7ffff2/.gitignore"
]
svn_pages = [
"svn-apache",
"svn-apache/annotate/672129/cocoon/trunk/README.txt",
"svn-apache/changelog",
"svn-apache/changeset/1164362",
"svn-apache/compare/rev@1164350...rev@1164360?target_repo=svn-apache",
"svn-apache/compare/rev@1164300...rev@1164360?target_repo=svn-apache",
"svn-apache/files/tip/",
"svn-apache/files/1164363/cocoon/trunk/README.txt",
]
# Uncomment to check also svn performance
# pages = pages + svn_pages
repeat = 10
print("Repeating each URL x%d\n" % repeat)
for page in pages:
url = "http://%s/%s" % (server, page)
print(url)
stmt = "urllib2.urlopen('%s', timeout=120)" % url
t = timeit.Timer(stmt=stmt, setup="import urllib2")
result = t.repeat(repeat=repeat, number=1)
print("\t%.3f (min) - %.3f (max) - %.3f (avg)\n" %
(min(result), max(result), sum(result)/len(result)))

View file

@ -108,12 +108,12 @@ class Repository(object):
self.name = name
self.path = os.path.join(base_path, name)
self.api = api
self.url = None
def create(self):
self._create_filesystem_repo(self.path)
try:
self.url = self.api.create_repo(
self.name, self.TYPE, 'Performance tests')
self.url = self.api.create_repo(self.name, self.TYPE, 'Performance tests')
except ApiError as e:
log.error('api: {}'.format(e))
@ -127,7 +127,7 @@ class Repository(object):
def create_commits(self, number, file_size):
for i in xrange(number):
file_name = self.FILE_NAME_TEMPLATE.format(i)
log.debug("Create commit {}".format(file_name))
log.debug("Create commit[{}] {}".format(self.name, file_name))
self._create_file(file_name, file_size)
self._create_commit(file_name)
@ -258,8 +258,8 @@ class Benchmark(object):
for operation in operations:
for type_ in repos:
times = self._measure(repos[type_], *operation)
print("Mean {} {} time: {:.3f} sec.".format(
type_, operation[0], mean(times)))
print("Mean[of {}] {:5s} {:5s} time: {:.3f} sec.".format(
len(times), type_, operation[0], mean(times)))
def cleanup(self):
log.info("Cleaning up...")
@ -296,6 +296,7 @@ class Benchmark(object):
log.addHandler(handler)
log.setLevel(log_level)
if __name__ == '__main__':
config = Config()
benchmark = Benchmark(config)