# HG changeset patch # User Marcin Kuzminski # Date 2019-07-09 13:53:44 # Node ID 0c0d4d8c507844026603ad69d6df228f2a13171a # Parent d0cfe4e5822c991d69b0756d0a0b4e4a5410cc40 tests: updated load tests CLIs diff --git a/rhodecode/tests/load/pages.txt b/rhodecode/tests/load/pages.txt new file mode 100644 --- /dev/null +++ b/rhodecode/tests/load/pages.txt @@ -0,0 +1,2 @@ +big/CPython +big/CPython/commits diff --git a/rhodecode/tests/load/time_urls.py b/rhodecode/tests/load/time_urls.py --- a/rhodecode/tests/load/time_urls.py +++ b/rhodecode/tests/load/time_urls.py @@ -19,51 +19,55 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ import timeit +import logging +import click -server = "localhost:5000" +log = logging.getLogger(__name__) + -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" -] +@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") -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", -] + result = t.repeat(repeat=repeat, number=1) + print(" %.3f (min) - %.3f (max) - %.3f (avg)\n" % + (min(result), max(result), sum(result) / len(result))) + -# Uncomment to check also svn performance -# pages = pages + svn_pages +if __name__ == '__main__': + main() + + + + + + + -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))) + + + diff --git a/rhodecode/tests/load/vcs_performance.py b/rhodecode/tests/load/vcs_performance.py --- a/rhodecode/tests/load/vcs_performance.py +++ b/rhodecode/tests/load/vcs_performance.py @@ -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)