Skip to content

Commit 92ec2d6

Browse files
committed
update benchmarks
1 parent f8f529b commit 92ec2d6

File tree

6 files changed

+32
-74
lines changed

6 files changed

+32
-74
lines changed

benchmark/__init__.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import faker
21
import MySQLdb
32
import pymysql
43

@@ -8,15 +7,14 @@
87
conn_mysqlclient = MySQLdb.connect(**connection_kwargs)
98
conn_pymysql = pymysql.connect(**connection_kwargs)
109
COUNT = 50000
11-
faker = faker.Faker()
1210

1311
data = [
1412
(
1513
1,
16-
faker.date_time().date(),
17-
faker.date_time(),
14+
"2021-01-01",
15+
"2020-07-16 22:49:54",
1816
1,
19-
faker.name(),
17+
"asyncmy",
2018
1,
2119
)
2220
for _ in range(COUNT)

benchmark/benchmark_delete.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
from benchmark import COUNT, connection_kwargs
99
from benchmark.decorators import cleanup, fill_data
1010

11+
count = int(COUNT / 5)
12+
1113

1214
@cleanup
1315
@fill_data
1416
async def delete_asyncmy():
1517
conn = await asyncmy.connect(**connection_kwargs)
1618
async with conn.cursor() as cur:
1719
t = time.time()
18-
for i in range(COUNT):
20+
for i in range(count):
1921
ret = await cur.execute("delete from test.asyncmy where `id`=%s", (i + 1,))
2022
assert ret == 1
2123
return time.time() - t
@@ -27,7 +29,7 @@ async def delete_aiomysql():
2729
conn = await aiomysql.connect(**connection_kwargs)
2830
async with conn.cursor() as cur:
2931
t = time.time()
30-
for i in range(COUNT):
32+
for i in range(count):
3133
ret = await cur.execute("delete from test.asyncmy where `id`=%s", (i + 1,))
3234
assert ret == 1
3335
return time.time() - t
@@ -39,7 +41,7 @@ def delete_mysqlclient():
3941
conn = MySQLdb.connect(**connection_kwargs)
4042
cur = conn.cursor()
4143
t = time.time()
42-
for i in range(COUNT):
44+
for i in range(count):
4345
ret = cur.execute("delete from test.asyncmy where `id`=%s", (i + 1,))
4446
assert ret == 1
4547
return time.time() - t
@@ -51,7 +53,7 @@ def delete_pymysql():
5153
conn = pymysql.connect(**connection_kwargs)
5254
cur = conn.cursor()
5355
t = time.time()
54-
for i in range(COUNT):
56+
for i in range(count):
5557
ret = cur.execute("delete from test.asyncmy where `id`=%s", (i + 1,))
5658
assert ret == 1
5759
return time.time() - t

benchmark/benchmark_update.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88
from benchmark import COUNT, connection_kwargs
99
from benchmark.decorators import cleanup, fill_data
1010

11+
count = int(COUNT / 5)
12+
1113

1214
@cleanup
1315
@fill_data
1416
async def update_asyncmy():
1517
conn = await asyncmy.connect(**connection_kwargs)
1618
async with conn.cursor() as cur:
1719
t = time.time()
18-
for i in range(COUNT):
20+
for i in range(count):
1921
await cur.execute(
2022
"update test.asyncmy set `string`=%s where `id` = %s",
2123
(
@@ -32,7 +34,7 @@ async def update_aiomysql():
3234
conn = await aiomysql.connect(**connection_kwargs)
3335
async with conn.cursor() as cur:
3436
t = time.time()
35-
for i in range(COUNT):
37+
for i in range(count):
3638
await cur.execute(
3739
"update test.asyncmy set `string`=%s where `id` = %s",
3840
(
@@ -49,7 +51,7 @@ def update_mysqlclient():
4951
conn = MySQLdb.connect(**connection_kwargs)
5052
cur = conn.cursor()
5153
t = time.time()
52-
for i in range(COUNT):
54+
for i in range(count):
5355
cur.execute(
5456
"update test.asyncmy set `string`=%s where `id` = %s",
5557
(
@@ -66,7 +68,7 @@ def update_pymysql():
6668
conn = pymysql.connect(**connection_kwargs)
6769
cur = conn.cursor()
6870
t = time.time()
69-
for i in range(COUNT):
71+
for i in range(count):
7072
cur.execute(
7173
"update test.asyncmy set `string`=%s where `id` = %s",
7274
(

benchmark/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
`string` varchar(200) DEFAULT NULL,
4545
`tinyint` tinyint DEFAULT NULL,
4646
PRIMARY KEY (`id`)
47-
) ENGINE=InnoDB AUTO_INCREMENT=400001 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"""
47+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci"""
4848
)
4949
cur.execute("truncate table test.asyncmy")
5050

poetry.lock

+16-59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ pymysql = "*"
3333
aiomysql = "*"
3434
uvloop = "*"
3535
cryptography = "*"
36-
faker = "*"
3736

3837
[build-system]
3938
requires = ["poetry-core>=1.0.0", "setuptools", "cython"]

0 commit comments

Comments
 (0)