Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92134462
performance.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Nov 17, 16:19
Size
1 KB
Mime Type
text/x-python
Expires
Tue, Nov 19, 16:19 (2 d)
Engine
blob
Format
Raw Data
Handle
22379732
Attached To
R10834 Project_multiproc
performance.py
View Options
#!/usr/bin/python
import
os
import
numpy
as
np
from
numpy
import
array
testdir
=
"tests"
os
.
system
(
"mkdir -p "
+
testdir
)
Ntr
=
[
1
,
2
,
4
,
8
,
16
]
#sample = "Running the algorithm with 4 threads on 10000 by 10000 array for 5 iterations took 1.547 seconds"
def
loadtimes
(
fstream
):
t
=
[]
for
line
in
fstream
:
# skip if no information is contained
if
not
line
.
startswith
(
"Running the algorithm"
):
continue
values
=
line
.
split
(
' '
)
# split into string set
values
=
[
i
for
i
in
values
if
i
!=
''
]
# fliter null strings
t
.
append
(
float
(
values
[
15
]))
# 16-th value should contain the elapsed time
return
t
T
=
[]
# times
for
filename
in
os
.
listdir
(
os
.
getcwd
()
+
'/'
+
testdir
):
with
open
(
os
.
path
.
join
(
os
.
getcwd
()
+
'/'
+
testdir
,
filename
),
'r'
)
as
f
:
t
=
np
.
array
(
loadtimes
(
f
))
T
.
append
(
t
)
Tmean
=
np
.
mean
(
T
,
axis
=
0
)
.
tolist
()
Tsq
=
np
.
sqrt
(
np
.
var
(
T
,
axis
=
0
))
.
tolist
()
# compute mean and variance of arrays
# output values
out
=
open
(
"times.txt"
,
'w'
)
print
(
"ntr t dt"
,
file
=
out
)
for
(
ntr
,
t
,
dt
)
in
zip
(
Ntr
,
Tmean
,
Tsq
):
print
(
"
%d
%.3g
%.3g
"
%
(
ntr
,
t
,
dt
),
file
=
out
)
out
.
close
()
Event Timeline
Log In to Comment