11 IgProfProfile={
'PERF_TICKS':
'IgProfPerf',
12 'MEM_TOTAL':
'IgProfMem',
13 'MEM_LIVE':
'IgProfMem',
18 print '[IgAnalysis] %s ...' %command
20 exitstate=os.system(command)
25 """This function takes as arguments:
26 -a compressed (.gz) igprof output profile
27 -the output directory where to store the output
28 -the type of output wanted
29 Based on this information it automatically selects the igprof counter
30 (PERF_TICKS, MEM_TOTAL or MEM_LIVE) to use with igprof-analyse and it
31 performs the analysis.
32 If ASCII output_type is given, it keeps only the first seven lines of
33 the output file (the report) allowing quick access to the totals for
34 the counters in order to put together summary tables.
35 If SQLite3 output_type is given, it simply dumps the full reports in
36 sqlite3 format, ready to be browsed by igprof-navigator GUI (standalone
41 outfile=profile_name.split(
".")[0].
replace(IgProfProfile[AnalysisType],AnalysisType)+
".res"
48 if output_type ==
"SQLite3":
50 outfile= outfile[:-3]+
"sql3"
51 command=
'igprof-analyse --sqlite -d -v -g -r %s %s |sqlite3 %s'%(AnalysisType,profile_name,outfile)
54 elif output_type ==
"ASCII":
56 command=
'igprof-analyse -d -v -g -r %s %s > %s'%(AnalysisType,profile_name,outfile)
61 print "Reading the res file"
62 txt_file=open(outfile,
'r')
63 txt_file_content=txt_file.readlines()
64 print "res file has %s lines!"%len(txt_file_content)
67 print "Overwriting the res file, to reduce it to 7 lines"
68 out_file=open(outfile,
'w')
70 for line
in txt_file_content:
82 This function takes as arguments:
83 -a compressed (.gz) igprof output profile
84 -a second compressed (.gz) igprof output profile against which a regression analysis is intended to be done
85 -the output directory where to store the output of the regression analysis
86 Based on this information it automatically selects the igprof counter (PERF_TICKS, MEM_TOTAL or MEM_LIVE) to use
87 with igprof-analyse and it performs the regression analysis with SQLite3 output.
90 outfile=profile_name.split(
".")[0].
replace(IgProfProfile[AnalysisType],AnalysisType)+
"_diff_"+regression_profile_name.split(
".")[0].
split(
"___")[-1]+
".sql3"
91 command=
'igprof-analyse --sqlite -d -v -g --diff-mode -b %s -r %s %s |sqlite3 %s'%(regression_profile_name, AnalysisType,profile_name,outfile)
98 This function takes as arguments:
99 -a compressed (.gz) igprof output profile
100 -the output directory where to store the output of the igprof-analysis merging the results by library
101 Based on this information it automatically selects the igprof counter (PERF_TICKS, MEM_TOTAL or MEM_LIVE) to use
102 with igprof-analyse and it performs the igprof-analyse analysis merging the results by library and saving the results
103 in the usual igprof-navigator browseable SQLite3 format.
106 outfile=profile_name.split(
".")[0].
replace(IgProfProfile[AnalysisType],AnalysisType)+
"_merged"+
".sql3"
108 command=
"igprof-analyse --sqlite -d -v -g -r %s -ml -mr 's|.*/(.*)$|\\1|' %s |sqlite3 %s"%(AnalysisType,profile_name,outfile)
116 if __name__ ==
'__main__':
121 usage=
'IgProf_Analysis.py <options>'
122 parser = optparse.OptionParser(usage)
123 parser.add_option(
'-i',
'--in_ profile',
124 help=
'The profile to manipulate' ,
128 parser.add_option(
'-c',
'--counter',
129 help=
'The IgProf counter for the analysis (PERF_TICKS,MEM_TOTAL,MEM_LIVE,MEM_MAX)' ,
130 default=
'UNKNOWN_COUNTER',
132 parser.add_option(
'-t',
'--output_type',
133 help=
'The type of the output file (ASCII or sqlite3)' ,
136 parser.add_option(
'-r',
'--regression',
137 help=
'The IgProf output file to make a regression analysis against' ,
139 dest=
'regressionprofile')
140 parser.add_option(
'-l',
'--library',
141 help=
'Perform igprof-analyse merging the results by library',
145 (options,args) = parser.parse_args()
148 if options.profile==
'':
149 raise(
'Please select a profile, an output dir AND a type of output (ASCII or SQLITE3)!')
151 if not os.path.exists(options.profile):
152 raise (
'Input profile not present!')
154 AnalysisType=options.counter
156 print "Input file is %s and AnalysisType is %s"%(options.profile,AnalysisType)
159 if options.regressionprofile:
161 elif options.library:
def simple_igprof_analysis
def library_igprof_analysis