Skip to content

Commit

Permalink
test case for alter perf
Browse files Browse the repository at this point in the history
  • Loading branch information
tantaman committed Nov 21, 2023
1 parent 35584c4 commit c2639c4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py/correctness/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

# source env/bin/activate
# python -m pytest tests -s -k test_cl_merging
python3 -m pytest tests -s
python3 -m pytest tests -s -k test_commit_alter_perf
32 changes: 32 additions & 0 deletions py/correctness/tests/test_commit_alter_perf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from crsql_correctness import connect, close, min_db_v
from pprint import pprint
import pytest
import time

def test_commit_alter_perf():
c = connect(":memory:")
c.execute("CREATE TABLE issue (id INTEGER PRIMARY KEY NOT NULL, title TEXT, owner TEXT, status INTEGER, priority INTEGER)")
c.execute("SELECT crsql_as_crr('issue')")
c.commit()

start_time = time.time()
for i in range(10_000):
c.execute("INSERT INTO issue (title, owner, status, priority) VALUES ('title', 'owner', 1, 1)")
c.commit()
end_time = time.time()
print(f"insert time: {end_time - start_time}")

start_time = time.time()
c.execute("SELECT crsql_begin_alter('issue')")
c.execute("SELECT crsql_commit_alter('issue')")
end_time = time.time()
print(f"no alter alter time: {end_time - start_time}")

start_time = time.time()
c.execute("SELECT crsql_begin_alter('issue')")
c.execute("ALTER TABLE issue ADD COLUMN description TEXT")
c.execute("SELECT crsql_commit_alter('issue')")
end_time = time.time()
print(f"alter add col time: {end_time - start_time}")

None

0 comments on commit c2639c4

Please sign in to comment.