From 065adcf75bffec0bc6da96c5345d306eafcc4bab Mon Sep 17 00:00:00 2001 From: Bojan Serafimov Date: Tue, 13 Sep 2022 16:38:46 -0400 Subject: [PATCH] Measure duration --- test_runner/performance/test_trace_replay.py | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/test_runner/performance/test_trace_replay.py b/test_runner/performance/test_trace_replay.py index 75213a4abf..4f8fa06e64 100644 --- a/test_runner/performance/test_trace_replay.py +++ b/test_runner/performance/test_trace_replay.py @@ -1,9 +1,14 @@ from contextlib import closing +from fixtures.benchmark_fixture import NeonBenchmarker from fixtures.neon_fixtures import NeonEnvBuilder, ReplayBin -def test_trace_replay(neon_env_builder: NeonEnvBuilder, replay_bin: ReplayBin): +# This test is a demonstration of how to do trace playback. With the current +# workload it uses it's not testing anything meaningful. +def test_trace_replay( + neon_env_builder: NeonEnvBuilder, replay_bin: ReplayBin, zenbenchmark: NeonBenchmarker +): neon_env_builder.num_safekeepers = 1 env = neon_env_builder.init_start() @@ -15,16 +20,17 @@ def test_trace_replay(neon_env_builder: NeonEnvBuilder, replay_bin: ReplayBin): env.neon_cli.create_timeline("test_trace_replay", tenant_id=tenant) pg = env.postgres.create_start("test_trace_replay", "main", tenant) - pg.safe_psql("select 1;") - pg.safe_psql("select 1;") - pg.safe_psql("select 1;") - pg.safe_psql("select 1;") + with zenbenchmark.record_duration("run"): + pg.safe_psql("select 1;") + pg.safe_psql("select 1;") + pg.safe_psql("select 1;") + pg.safe_psql("select 1;") - with closing(pg.connect()) as conn: - with conn.cursor() as cur: - cur.execute("create table t (i integer);") - cur.execute(f"insert into t values (generate_series(1,{10000}));") - cur.execute("select count(*) from t;") + with closing(pg.connect()) as conn: + with conn.cursor() as cur: + cur.execute("create table t (i integer);") + cur.execute(f"insert into t values (generate_series(1,{10000}));") + cur.execute("select count(*) from t;") # Stop pg so we drop the connection and flush the traces pg.stop() @@ -37,5 +43,6 @@ def test_trace_replay(neon_env_builder: NeonEnvBuilder, replay_bin: ReplayBin): print("replaying") ps_connstr = env.pageserver.connstr() # ps_connstr = "host=localhost port=15004 dbname=postgres user=neon_admin" - output = replay_bin.replay_all(ps_connstr) + with zenbenchmark.record_duration("replay"): + output = replay_bin.replay_all(ps_connstr) print(output)