Skip to content

Commit 56aa0c6

Browse files
Implemented threading via ThreadingPool
1 parent c73d3a7 commit 56aa0c6

File tree

4 files changed

+57
-49
lines changed

4 files changed

+57
-49
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ __pycache__/
1111
/manual_test.py
1212
/dev/config.yaml
1313
/config.yaml
14+
/dev/my_gitmodules/
15+
/dev/my_libs/

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,8 @@ not_gitmodules install -y </path/to/notgitmodules.yaml> -d <directory_name> -t
168168

169169
---
170170
## Comparison
171-
For eleven repos with undefined amount of workers in `ThereadPool` :
171+
Usually with undefined amount of workers in `ThereadPool` in parallel mode take more than **52%** less time than in parallel mode.
172172

173-
- The execution of in sequential mode took 35.13206000009086 seconds.
174-
- The execution of in parallel mode took 16.677515499992296 seconds.
175-
176-
We get **52.53%** performance boost.
177173

178174
---
179175

dev/speed_comparison.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

speed_comparison.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os.path
2+
import time
3+
from not_gitmodules import initializer
4+
import shutil
5+
6+
7+
def timer_wrapper(root_dir_name):
8+
if os.path.exists(root_dir_name):
9+
shutil.rmtree(root_dir_name)
10+
11+
def timer(func):
12+
nonlocal root_dir_name
13+
14+
def executor():
15+
start = time.perf_counter()
16+
func(root_dir_name=root_dir_name)
17+
end = time.perf_counter()
18+
return f'The execution of {func.__name__} took {end - start} seconds.'
19+
20+
return executor
21+
22+
return timer
23+
24+
25+
@timer_wrapper(root_dir_name='dev/my_libs')
26+
def test_sequentially(root_dir_name):
27+
initializer(
28+
yaml_config_path='dev/config.yaml',
29+
download_in_threads=False,
30+
root_dir_name=root_dir_name
31+
)
32+
33+
34+
@timer_wrapper(root_dir_name='dev/my_gitmodules')
35+
def test_parallely(root_dir_name):
36+
initializer(
37+
yaml_config_path='dev/config.yaml',
38+
download_in_threads=True,
39+
root_dir_name=root_dir_name
40+
)
41+
42+
43+
def compare():
44+
result1 = test_sequentially()
45+
time.sleep(2)
46+
result2 = test_parallely()
47+
48+
print(70 * '=')
49+
print(result1)
50+
print(result2)
51+
52+
53+
if __name__ == '__main__':
54+
compare()

0 commit comments

Comments
 (0)