[wip] performance comparison

This commit is contained in:
Alexander Kuzmenkov 2020-01-21 21:15:25 +03:00
parent 1faf7016ce
commit 754c206203

View File

@ -1,5 +1,6 @@
#!/usr/bin/python3
import os
import sys
import itertools
import clickhouse_driver
@ -12,6 +13,9 @@ import traceback
parser = argparse.ArgumentParser(description='Run performance test.')
# Explicitly decode files as UTF-8 because sometimes we have Russian characters in queries, and LANG=C is set.
parser.add_argument('file', metavar='FILE', type=argparse.FileType('r', encoding='utf-8'), nargs=1, help='test description file')
parser.add_argument('--host', nargs='*', default=['127.0.0.1', '127.0.0.1'])
parser.add_argument('--port', nargs='*', default=[9001, 9002])
parser.add_argument('--runs', type=int, default=int(os.environ.get('CHPC_RUNS', 7)))
args = parser.parse_args()
tree = et.parse(args.file[0])
@ -28,7 +32,7 @@ if infinite_sign is not None:
raise Exception('Looks like the test is infinite (sign 1)')
# Open connections
servers = [{'host': 'localhost', 'port': 9001, 'client_name': 'left'}, {'host': 'localhost', 'port': 9002, 'client_name': 'right'}]
servers = [{'host': host, 'port': port} for (host, port) in zip(args.host, args.port)]
connections = [clickhouse_driver.Client(**server) for server in servers]
# Check tables that should exist
@ -95,7 +99,7 @@ for q in test_queries:
# excessive data.
start_seconds = time.perf_counter()
server_seconds = 0
for run in range(0, 13):
for run in range(0, args.runs):
for conn_index, c in enumerate(connections):
res = c.execute(q)
print('query\t' + tsv_escape(q) + '\t' + str(run) + '\t' + str(conn_index) + '\t' + str(c.last_query.elapsed))