Skip to content

Commit 509ff26

Browse files
committed
Add listing benchmark
1 parent 6a753c4 commit 509ff26

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

python/tests/test_benchmark.py

+23-12
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,31 @@
66
from hdfs_native import Client
77

88

9-
def do_work(client: Client):
10-
def func(path: str):
11-
client.create(path).close()
12-
return client.delete(path)
9+
@pytest.mark.benchmark
10+
def test_benchmark_threading(client: Client, benchmark: BenchmarkFixture):
11+
def do_work():
12+
def func(path: str):
13+
client.create(path).close()
14+
return client.delete(path)
15+
16+
with ThreadPoolExecutor(100) as executor:
17+
futures = []
18+
for i in range(1000):
19+
futures.append(executor.submit(func, f"/bench{i}"))
1320

14-
with ThreadPoolExecutor(100) as executor:
15-
futures = []
16-
for i in range(1000):
17-
futures.append(executor.submit(func, f"/bench{i}"))
21+
for future in as_completed(futures):
22+
assert future.result()
1823

19-
for future in as_completed(futures):
20-
assert future.result()
24+
benchmark(do_work)
2125

2226

2327
@pytest.mark.benchmark
24-
def test_threading(client: Client, benchmark: BenchmarkFixture):
25-
benchmark(do_work, client)
28+
def test_benchmark_listing(client: Client, benchmark: BenchmarkFixture):
29+
for i in range(1000):
30+
client.create(f"/bench{i}").close()
31+
32+
def do_work():
33+
for _ in client.list_status("/"):
34+
pass
35+
36+
benchmark(do_work)

0 commit comments

Comments
 (0)