Skip to content

Commit

Permalink
Add performance tuning tutorial and script
Browse files Browse the repository at this point in the history
  • Loading branch information
jseldess committed Aug 11, 2018
1 parent 82ec81f commit 87c1f10
Show file tree
Hide file tree
Showing 12 changed files with 2,332 additions and 0 deletions.
6 changes: 6 additions & 0 deletions _includes/sidebar-data-v2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,12 @@
"/${VERSION}/performance-benchmarking-with-tpc-c.html"
]
},
{
"title": "Performance Tuning",
"urls": [
"/${VERSION}/performance-tuning.html"
]
},
{
"title": "Access Management",
"items": [
Expand Down
54 changes: 54 additions & 0 deletions _includes/v2.0/performance/tuning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import argparse
import psycopg2
import time

parser = argparse.ArgumentParser(
description="test performance of statements against movr database")
parser.add_argument("--host", required=True,
help="ip address of one of the CockroachDB nodes")
parser.add_argument("--statement", required=True,
help="statement to execute")
parser.add_argument("--repeat", type=int,
help="number of times to repeat the statement", default = 20)
parser.add_argument("--times",
help="print time for each repetition of the statement", action="store_true")
parser.add_argument("--cumulative",
help="print cumulative time for all repetitions of the statement", action="store_true")
args = parser.parse_args()

conn = psycopg2.connect(database='movr', user='root', host=args.host, port=26257)
conn.set_session(autocommit=True)
cur = conn.cursor()

times = list()
for n in range(args.repeat):
start = time.time()
statement = args.statement
cur.execute(statement)
if n < 1:
if cur.description is not None:
colnames = [desc[0] for desc in cur.description]
print("")
print("Result:")
print(colnames)
rows = cur.fetchall()
for row in rows:
print([str(cell) for cell in row])
end = time.time()
times.append((end - start)* 1000)

cur.close()
conn.close()

print("")
if args.times:
print("Times (milliseconds):")
print(times)
print("")
print("Average time (milliseconds):")
print(float(sum(times))/len(times))
print("")
if args.cumulative:
print("Cumulative time (milliseconds):")
print(sum(times))
print("")
Binary file added images/v2.0/perf_tuning_concepts1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_concepts2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_concepts3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_concepts4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_movr_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_multi_region_topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,272 changes: 2,272 additions & 0 deletions v2.0/performance-tuning.md

Large diffs are not rendered by default.

0 comments on commit 87c1f10

Please sign in to comment.