Files
dbbench/mysql-network-latency-public.py

25 lines
497 B
Python
Raw Permalink Normal View History

2019-01-29 00:34:24 +00:00
#!/usr/bin/python3
import time
import MySQLdb
############
SAMPLES = 10000
############
MICROSECONDS_PER_SECOND = 1000000
db = MySQLdb.connect(host='35.235.123.231', user='root', password='foobar', db='benchmark')
c = db.cursor()
def MeanExecutionTime(samples):
start = time.perf_counter()
for _ in range(samples):
c.execute('SELECT 1')
end = time.perf_counter()
return (end - start) / samples
print('%dus' % (MeanExecutionTime(SAMPLES) * MICROSECONDS_PER_SECOND))