8 from __future__
import print_function
12 IgProfProfile={
'PERF_TICKS':
'IgProfPerf',
13 'MEM_TOTAL':
'IgProfMem',
14 'MEM_LIVE':
'IgProfMem',
19 print(
'[IgAnalysis] %s ...' %command)
21 exitstate=os.system(command)
26 """This function takes as arguments: 27 -a compressed (.gz) igprof output profile 28 -the output directory where to store the output 29 -the type of output wanted 30 Based on this information it automatically selects the igprof counter 31 (PERF_TICKS, MEM_TOTAL or MEM_LIVE) to use with igprof-analyse and it 32 performs the analysis. 33 If ASCII output_type is given, it keeps only the first seven lines of 34 the output file (the report) allowing quick access to the totals for 35 the counters in order to put together summary tables. 36 If SQLite3 output_type is given, it simply dumps the full reports in 37 sqlite3 format, ready to be browsed by igprof-navigator GUI (standalone 42 outfile=profile_name.split(
".")[0].
replace(IgProfProfile[AnalysisType],AnalysisType)+
".res" 49 if output_type ==
"SQLite3":
51 outfile= outfile[:-3]+
"sql3" 52 command=
'igprof-analyse --sqlite -d -v -g -r %s %s |sqlite3 %s'%(AnalysisType,profile_name,outfile)
55 elif output_type ==
"ASCII":
57 command=
'igprof-analyse -d -v -g -r %s %s > %s'%(AnalysisType,profile_name,outfile)
62 print(
"Reading the res file")
63 txt_file=open(outfile,
'r') 64 txt_file_content=txt_file.readlines() 65 print(
"res file has %s lines!"%len(txt_file_content))
68 print(
"Overwriting the res file, to reduce it to 7 lines")
69 out_file=open(outfile,
'w')
71 for line
in txt_file_content:
83 This function takes as arguments: 84 -a compressed (.gz) igprof output profile 85 -a second compressed (.gz) igprof output profile against which a regression analysis is intended to be done 86 -the output directory where to store the output of the regression analysis 87 Based on this information it automatically selects the igprof counter (PERF_TICKS, MEM_TOTAL or MEM_LIVE) to use 88 with igprof-analyse and it performs the regression analysis with SQLite3 output. 91 outfile=profile_name.split(
".")[0].
replace(IgProfProfile[AnalysisType],AnalysisType)+
"_diff_"+regression_profile_name.split(
".")[0].
split(
"___")[-1]+
".sql3" 92 command=
'igprof-analyse --sqlite -d -v -g --diff-mode -b %s -r %s %s |sqlite3 %s'%(regression_profile_name, AnalysisType,profile_name,outfile)
99 This function takes as arguments: 100 -a compressed (.gz) igprof output profile 101 -the output directory where to store the output of the igprof-analysis merging the results by library 102 Based on this information it automatically selects the igprof counter (PERF_TICKS, MEM_TOTAL or MEM_LIVE) to use 103 with igprof-analyse and it performs the igprof-analyse analysis merging the results by library and saving the results 104 in the usual igprof-navigator browseable SQLite3 format. 107 outfile=profile_name.split(
".")[0].
replace(IgProfProfile[AnalysisType],AnalysisType)+
"_merged"+
".sql3" 109 command=
"igprof-analyse --sqlite -d -v -g -r %s -ml -mr 's|.*/(.*)$|\\1|' %s |sqlite3 %s"%(AnalysisType,profile_name,outfile)
117 if __name__ ==
'__main__':
122 usage=
'IgProf_Analysis.py <options>' 123 parser = optparse.OptionParser(usage)
124 parser.add_option(
'-i',
'--in_ profile',
125 help=
'The profile to manipulate' ,
129 parser.add_option(
'-c',
'--counter',
130 help=
'The IgProf counter for the analysis (PERF_TICKS,MEM_TOTAL,MEM_LIVE,MEM_MAX)' ,
131 default=
'UNKNOWN_COUNTER',
133 parser.add_option(
'-t',
'--output_type',
134 help=
'The type of the output file (ASCII or sqlite3)' ,
137 parser.add_option(
'-r',
'--regression',
138 help=
'The IgProf output file to make a regression analysis against' ,
140 dest=
'regressionprofile')
141 parser.add_option(
'-l',
'--library',
142 help=
'Perform igprof-analyse merging the results by library',
146 (options,args) = parser.parse_args()
149 if options.profile==
'':
150 raise(
'Please select a profile, an output dir AND a type of output (ASCII or SQLITE3)!')
152 if not os.path.exists(options.profile):
153 raise (
'Input profile not present!')
155 AnalysisType=options.counter
157 print(
"Input file is %s and AnalysisType is %s"%(options.profile,AnalysisType))
160 if options.regressionprofile:
162 elif options.library:
def library_igprof_analysis(profile_name, AnalysisType)
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
def simple_igprof_analysis(profile_name, AnalysisType, output_type)
def diff_igprof_analysis(profile_name, regression_profile_name, AnalysisType)