mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 01:12:56 +00:00
Measure duration
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user