ATLAS Offline Software
Functions
aprof Namespace Reference

Functions

def main ()
 C++ style main function. More...
 
def makePdf (input_file, output_file)
 Function making a PDF file from the profile file. More...
 
def makeCallgrind (input_file, output_file)
 Function making a callgrind file from the profile file. More...
 

Function Documentation

◆ main()

def aprof.main ( )

C++ style main function.

This function takes care of running pprof with the correct arguments

Returns
The status code returned by pprof

Definition at line 18 of file aprof.py.

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 

◆ makeCallgrind()

def aprof.makeCallgrind (   input_file,
  output_file 
)

Function making a callgrind file from the profile file.

This function is used to make a callgrind file from the profile file produced by gathena.py.

Parameters
input_fileProfile file created in a profiled job
output_fileName of the output PDF file to be created
Returns
The status code returned by the pprof command

Definition at line 96 of file aprof.py.

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 #

◆ makePdf()

def aprof.makePdf (   input_file,
  output_file 
)

Function making a PDF file from the profile file.

This function is used to make a meaningful PDF from the profile file produced by gathena.py.

Parameters
input_fileProfile file created in a profiled job
output_fileName of the output PDF file to be created
Returns
The status code returned by the pprof command

Definition at line 74 of file aprof.py.

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 
aprof.main
def main()
C++ style main function.
Definition: aprof.py:18
aprof.makePdf
def makePdf(input_file, output_file)
Function making a PDF file from the profile file.
Definition: aprof.py:74
pool::DbPrintLvl::setLevel
void setLevel(MsgLevel l)
Definition: DbPrint.h:32
aprof.makeCallgrind
def makeCallgrind(input_file, output_file)
Function making a callgrind file from the profile file.
Definition: aprof.py:96