Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c9be70

Browse filesBrowse files
author
Ilya Gurov
authored
Create BENCHMARKS.md (googleapis#102)
1 parent 54c95e8 commit 1c9be70
Copy full SHA for 1c9be70

File tree

Expand file treeCollapse file tree

2 files changed

+35
-6
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+35
-6
lines changed

‎BENCHMARKS.md

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Benchmarks
2+
3+
The performance test suite is located in [test/benchmark.py](https://github.com/cloudspannerecosystem/python-spanner-sqlalchemy/blob/main/test/benchmark.py) and intended to compare execution time difference between SQLAlchemy dialect for Spanner and pure Spanner client.
4+
5+
The test suite requirements:
6+
- `scipy` Python package installed
7+
- the original dialect requirements
8+
9+
Use `PROJECT`, `INSTANCE` and `DATABASE` module constants to set a project to execute tests on.
10+
11+
# 07-11-2021
12+
13+
|Test|mean, sec|error|std_dev|
14+
|----|-------|-----|--------|
15+
|SPANNER insert_one_row_with_fetch_after| 0.91|0.01|0.09|
16+
|ALCHEMY insert_one_row_with_fetch_after| 1.07| 0.0|0.03|
17+
|SPANNER read_one_row| 0.33| 0.0| 0.01|
18+
|ALCHEMY read_one_row| 0.3| 0.0| 0.01|
19+
|SPANNER insert_many_rows| 1.37| 0.02| 0.12|
20+
|ALCHEMY insert_many_rows| 24.41| 0.07| 0.49|
21+
|SPANNER select_many_rows| 0.31| 0.02| 0.08|
22+
|ALCHEMY select_many_rows| 0.22| 0.03| 0.01|
23+
|SPANNER insert_many_rows_with_mutations| 0.34| 0.0| 0.03|
24+
|SQLALCHEMY insert_many_rows_with_mutations| 25.1| 0.03| 0.31|

‎test/benchmark.py

Copy file name to clipboardExpand all lines: test/benchmark.py
+11-6Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
Table,
3535
)
3636

37+
PROJECT = "project-id"
38+
INSTANCE = "instance-id"
39+
DATABASE = "database-id"
40+
3741

3842
def measure_execution_time(function):
3943
"""Decorator to measure a wrapped method execution time."""
@@ -73,13 +77,13 @@ def __init__(self):
7377

7478
def _cleanup(self):
7579
"""Drop the test table."""
76-
conn = spanner_dbapi.connect("sqlalchemy-dialect-test", "compliance-test")
80+
conn = spanner_dbapi.connect(INSTANCE, DATABASE)
7781
conn.database.update_ddl(["DROP TABLE Singers"])
7882
conn.close()
7983

8084
def _create_table(self):
8185
"""Create a table for performace testing."""
82-
conn = spanner_dbapi.connect("sqlalchemy-dialect-test", "compliance-test")
86+
conn = spanner_dbapi.connect(INSTANCE, DATABASE)
8387
conn.database.update_ddl(
8488
[
8589
"""
@@ -118,8 +122,8 @@ class SpannerBenchmarkTest(BenchmarkTestBase):
118122
def __init__(self):
119123
super().__init__()
120124
self._client = Client()
121-
self._instance = self._client.instance("sqlalchemy-dialect-test")
122-
self._database = self._instance.database("compliance-test")
125+
self._instance = self._client.instance(INSTANCE)
126+
self._database = self._instance.database(DATABASE)
123127

124128
self._many_rows = []
125129
self._many_rows2 = []
@@ -177,8 +181,9 @@ class SQLAlchemyBenchmarkTest(BenchmarkTestBase):
177181
def __init__(self):
178182
super().__init__()
179183
self._engine = create_engine(
180-
"spanner:///projects/appdev-soda-spanner-staging/instances/"
181-
"sqlalchemy-dialect-test/databases/compliance-test"
184+
"spanner:///projects/{project}/instances/{instance}/databases/{db}".format(
185+
project=PROJECT, instance=INSTANCE, db=DATABASE,
186+
)
182187
)
183188
metadata = MetaData(bind=self._engine)
184189
self._table = Table("Singers", metadata, autoload=True)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.