File tree 1 file changed +23
-12
lines changed
1 file changed +23
-12
lines changed Original file line number Diff line number Diff line change 6
6
from hdfs_native import Client
7
7
8
8
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 } " ))
13
20
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 ()
18
23
19
- for future in as_completed (futures ):
20
- assert future .result ()
24
+ benchmark (do_work )
21
25
22
26
23
27
@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 )
You can’t perform that action at this time.
0 commit comments