FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
async/async/test/test_performance.py at master · gitpython-developers/async · GitHub
This repository was archived by the owner on Apr 14, 2024. It is now read-only.
gitpython-developers
async
Repository navigation
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
async
/
async
/
test
/
test_performance.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
57 lines (49 loc) · 2.24 KB
Breadcrumbs
async
/
async
/
test
/
test_performance.py
Copy path
File metadata and controls
57 lines (49 loc) · 2.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors
#
# This module is part of async and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
"""Channel testing"""
from
.
lib
import
TestBase
from
.
task
import
(
add_task_chain
,
IteratorThreadTask
,
FixturePerformanceThreadTask
)
from
async
.
pool
import
ThreadPool
from
async
.
util
import
cpu_count
import
time
import
sys
class
TestThreadPoolPerformance
(
TestBase
):
max_threads
=
cpu_count
()
def
test_base
(
self
):
# create a dependency network, and see how the performance changes
# when adjusting the amount of threads
pool
=
ThreadPool
(
0
)
ni
=
1000
# number of items to process
for
num_threads
in
range
(
0
,
self
.
max_threads
*
2
+
1
,
self
.
max_threads
//
2
):
pool
.
set_size
(
num_threads
)
for
num_transformers
in
(
1
,
5
,
10
):
for
read_mode
in
range
(
2
):
ts
,
rcs
=
add_task_chain
(
pool
,
ni
,
count
=
num_transformers
,
feedercls
=
IteratorThreadTask
,
transformercls
=
FixturePerformanceThreadTask
,
include_verifier
=
False
)
mode_info
=
"read(0)"
if
read_mode
==
1
:
mode_info
=
"read(1) * %i"
%
ni
# END mode info
fmt
=
"Threadcount=%%i: Produced %%i items using %s in %%i transformations in %%f s (%%f items / s)
\n
"
%
mode_info
reader
=
rcs
[
-
1
]
st
=
time
.
time
()
if
read_mode
==
1
:
for
i
in
range
(
ni
):
assert
len
(
reader
.
read
(
1
))
==
1
# END for each item to read
else
:
assert
len
(
reader
.
read
(
0
))
==
ni
# END handle read mode
elapsed
=
time
.
time
()
-
st
sys
.
stderr
.
write
(
fmt
%
(
num_threads
,
ni
,
num_transformers
,
elapsed
,
ni
/
elapsed
))
# END for each read-mode
# END for each amount of processors
# END for each thread count
Back
|
FazBrowse Home
|
New Git URL