ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
PerformanceMonitoring
PerfMonGPerfTools
scripts
aprof.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
#
5
# $Id: aprof.py 783179 2016-11-09 11:13:54Z limosani $
6
#
7
# This is a helper script for quickly interpreting the profile file(s)
8
# produced by gathena.py.
9
#
10
11
18
def
main
():
19
20
# Set up a message logger:
21
import
sys
22
import
os.path
23
from
AthenaCommon.Logging
import
logging
24
logger = logging.getLogger( os.path.splitext( os.path.basename( sys.argv[ 0 ] ) )[ 0 ] )
25
26
# Read in the command line options:
27
import
optparse
28
desc =
"This is a simple helper script for easily turning profile files into "
\
29
"something that's more easily readable. It doesn't provide too many "
\
30
"options, but it prints everyhing that it's doing. So it's easy to "
\
31
"tweak a bit what it did. Usage instructions can be found on: "
\
32
"[Put TWiki here]"
33
vers =
"$Revision: 783179 $"
34
parser = optparse.OptionParser( description = desc,
35
version = vers,
36
usage =
"%prog [options] <profile file> <output file>"
)
37
parser.add_option(
"-v"
,
"--verbosity"
, dest =
"verbosity"
,
38
action =
"store"
, type =
"int"
, default = 3,
39
help =
"Script message verbosity level"
)
40
41
( options, files ) = parser.parse_args()
42
43
# A little sanity check:
44
if
len( files ) != 2:
45
logger.error(
"You have to provide one input and output file for the script!"
)
46
parser.print_help()
47
return
1
48
49
# Set the logging level:
50
logging.getLogger(
""
).setLevel( options.verbosity )
51
52
# Extract the file names:
53
input_file = files[ 0 ]
54
output_file = files[ 1 ]
55
56
# Make the output file based on the extension of it:
57
if
output_file.endswith(
".pdf"
):
58
return
makePdf
( input_file, output_file )
59
elif
output_file.endswith(
".callgrind"
):
60
return
makeCallgrind
( input_file, output_file )
61
else
:
62
logger.error(
"Output format not recognized"
)
63
return
1
64
65
74
def
makePdf
( input_file, output_file ):
75
76
# Set up a logger object:
77
from
AthenaCommon.Logging
import
logging
78
logger = logging.getLogger(
"makePdf"
)
79
80
# Construct and run the command:
81
import
os
82
command =
"pprof --pdf --nodecount=200 --nodefraction=0.001 "
\
83
"--edgefraction=0.0002 `which python` "
+ input_file +
" > "
+ output_file
84
logger.info(
"Running command: "
+ command )
85
return
os.system( command )
86
87
96
def
makeCallgrind
( input_file, output_file ):
97
98
# Set up a logger object:
99
from
AthenaCommon.Logging
import
logging
100
logger = logging.getLogger(
"makeCallgrind"
)
101
102
# Construct and run the command:
103
import
os
104
command =
"pprof --callgrind `which python` "
+ \
105
input_file +
" > "
+ output_file
106
logger.info(
"Running command: "
+ command )
107
return
os.system( command )
108
109
#
110
# Execute the main() function:
111
#
112
if
__name__ ==
"__main__"
:
113
import
sys
114
sys.exit(
main
() )
115
pass
aprof.makePdf
makePdf(input_file, output_file)
Function making a PDF file from the profile file.
Definition
aprof.py:74
aprof.main
main()
C++ style main function.
Definition
aprof.py:18
aprof.makeCallgrind
makeCallgrind(input_file, output_file)
Function making a callgrind file from the profile file.
Definition
aprof.py:96
Generated on
for ATLAS Offline Software by
1.17.0