Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100635299
gplot_cpu
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
Sat, Feb 1, 08:54
Size
3 KB
Mime Type
text/x-python
Expires
Mon, Feb 3, 08:54 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24004808
Attached To
rGTOOLS Gtools
gplot_cpu
View Options
#!/usr/bin/env python
'''
Extract and plot info contained in cpu.txt files
Yves Revaz
jeu avr 6 15:58:19 CEST 2006
'''
import
os
,
sys
,
string
from
optparse
import
OptionParser
import
SM
from
Gtools
import
*
from
Gtools
import
io
from
optparse
import
OptionParser
def
parse_options
():
usage
=
"usage: %prog [options] file"
parser
=
OptionParser
(
usage
=
usage
)
parser
=
add_postscript_options
(
parser
)
parser
=
add_color_options
(
parser
)
parser
=
add_limits_options
(
parser
)
parser
=
add_log_options
(
parser
)
parser
.
add_option
(
"--mode"
,
action
=
"store"
,
dest
=
"mode"
,
type
=
"string"
,
default
=
'Total'
,
help
=
"mode : cpu, cpu/step"
,
metavar
=
" NAME"
)
parser
.
add_option
(
"-t"
,
action
=
"store"
,
dest
=
"time"
,
type
=
"string"
,
default
=
'hour'
,
help
=
"time : day, hour, minute, second"
,
metavar
=
" TYPE"
)
(
options
,
args
)
=
parser
.
parse_args
()
if
options
.
colors
!=
None
:
exec
(
"options.colors = array([
%s
])"
%
(
options
.
colors
))
if
len
(
args
)
==
0
:
print
"you must specify a filename"
sys
.
exit
(
0
)
files
=
args
return
files
,
options
#############################
# graph
#############################
# get options
files
,
options
=
parse_options
()
ps
=
options
.
ps
col
=
options
.
colors
xmin
=
options
.
xmin
xmax
=
options
.
xmax
ymin
=
options
.
ymin
ymax
=
options
.
ymax
log
=
options
.
log
mode
=
options
.
mode
time
=
options
.
time
#######################################
# open sm
#######################################
g
=
Graph_Init
(
ps
)
Graph_SetDefaultsGraphSettings
(
g
)
colors
=
Graph_SetColorsForFiles
(
files
,
col
)
# read files
for
file
in
files
:
Step
,
Time
,
CPUs
,
CPU_Total
,
CPU_Gravity
,
CPU_Hydro
,
CPU_Domain
,
CPU_Potential
,
CPU_Predict
,
CPU_TimeLine
,
CPU_Snapshot
,
CPU_TreeWalk
,
CPU_TreeConstruction
,
CPU_CommSum
,
CPU_Imbalance
,
CPU_HydCompWalk
,
CPU_HydCommSumm
,
CPU_HydImbalance
,
CPU_EnsureNgb
,
CPU_PM
,
CPU_Peano
=
io
.
read_cpu
(
file
)
x
=
Time
if
time
==
'day'
:
f
=
1.
/
(
60.
*
60.
*
24.
)
elif
time
==
'hour'
:
f
=
1.
/
(
60.
*
60.
)
elif
time
==
'minute'
:
f
=
1.
/
(
60.
)
elif
time
==
'second'
:
f
=
1.
/
(
1.
)
if
mode
==
'Total'
:
y
=
CPU_Total
*
f
elif
mode
==
'Gravity'
:
y
=
CPU_Gravity
*
f
elif
mode
==
'Hydro'
:
y
=
CPU_Hydro
*
f
elif
mode
==
'Domain'
:
y
=
CPU_Domain
*
f
elif
mode
==
'Potential'
:
y
=
CPU_Potential
*
f
elif
mode
==
'Predict'
:
y
=
CPU_Predict
*
f
elif
mode
==
'TimeLine'
:
y
=
CPU_TimeLine
*
f
elif
mode
==
'Snapshot'
:
y
=
CPU_Snapshot
*
f
elif
mode
==
'TreeWalk'
:
y
=
CPU_TreeWalk
*
f
elif
mode
==
'TreeConstruction'
:
y
=
CPU_TreeConstruction
*
f
elif
mode
==
'CommSum'
:
y
=
CPU_CommSum
*
f
elif
mode
==
'Imbalance'
:
y
=
CPU_Imbalance
*
f
elif
mode
==
'HydCompWalk'
:
y
=
CPU_HydCompWalk
*
f
elif
mode
==
'HydCommSumm'
:
y
=
CPU_HydCommSumm
*
f
elif
mode
==
'HydImbalance'
:
y
=
CPU_HydImbalance
*
f
elif
mode
==
'EnsureNgb'
:
y
=
CPU_EnsureNgb
*
f
elif
mode
==
'PM'
:
y
=
CPU_PM
*
f
elif
mode
==
'CPU_Peano'
:
y
=
CPU_Peano
*
f
elif
mode
==
'HydroTot'
:
y
=
CPU_HydCompWalk
+
CPU_HydCommSumm
+
CPU_HydImbalance
+
CPU_EnsureNgb
y
=
y
*
f
elif
mode
==
'cpu/step'
:
x
=
x
[
1
:]
y
=
y
[
1
:]
-
y
[:
-
1
]
# use log
if
log
!=
None
:
x
,
y
=
Graph_UseLog
(
x
,
y
,
log
)
if
file
==
files
[
0
]:
xmin
,
xmax
,
ymin
,
ymax
=
Graph_SetLimits
(
g
,
xmin
,
xmax
,
ymin
,
ymax
,
x
,
y
)
g
.
box
()
# plot points
g
.
ctype
(
colors
[
file
])
g
.
connect
(
x
,
y
)
g
.
ctype
(
0
)
if
mode
==
'cpu/step'
:
g
.
xlabel
(
'Time'
)
g
.
ylabel
(
'CPUs/Step'
)
else
:
g
.
xlabel
(
'Time'
)
g
.
ylabel
(
'CPUs [
%s
]'
%
time
)
# -- end ---
Graph_End
(
g
,
ps
)
Event Timeline
Log In to Comment