def plotPerformanceData(csvLike, titleTemplate, outputTemplate, targetColumn, yLabel, patternMap, params, scale=Decimal(1.0), xRange='*:*', debug=False): """ params :: [(pattern :: str, bsU :: str, yRange :: str|None)] list of parameters. """ assert(isinstance(csvLike, CsvLike)) assert(isinstance(titleTemplate, str)) assert(isinstance(outputTemplate, str)) assert(isinstance(targetColumn, str)) assert(isinstance(yLabel, str)) assert(isinstance(patternMap, dict)) assert(isinstance(params, list)) assert(isinstance(scale, Decimal)) assert(isinstance(xRange, str)) assert(isinstance(debug, bool)) for pattern, blockSizeU, yRange in params: title = titleTemplate % (patternMap[pattern], blockSizeU) output = outputTemplate % (pattern, blockSizeU) blockSizeS = str(util.u2s(blockSizeU)) if yRange is None: yRange = '0:*' rp = PerformancePlot(csvLike, pattern, blockSizeS, targetColumn, yLabel, title, output, scale, xRange, yRange, debug) rp.plot()
def plotMultiData(relColLegList, titleTemplate, outputTemplate, yLabel, patternMap, params, scale=Decimal(1.0), xRange='*:*', debug=False): """ relColLegList :: [(rel, col, legend)] rel :: Relation col :: str target column name legend :: str legend title in the plot. Each legend must be unique in the list. params :: [(pattern :: str, mode :: str, bsU :: str, yRange :: str|None)] list of parameters. """ assert (isinstance(relColLegList, list)) assert (isinstance(titleTemplate, str)) assert (isinstance(outputTemplate, str)) assert (isinstance(yLabel, str)) assert (isinstance(patternMap, dict)) assert (isinstance(params, list)) assert (isinstance(scale, Decimal)) assert (isinstance(xRange, str)) assert (isinstance(debug, bool)) for pattern, mode, bsU, yRange in params: title = titleTemplate % (patternMap[pattern], mode, bsU) output = outputTemplate % (pattern, mode, bsU) bsS = str(util.u2s(bsU)) if yRange is None: yRange = '0:*' rp = MultiPlot(relColLegList, pattern, mode, bsS, yLabel, title, output, scale, xRange, yRange, debug) rp.plot() pass
def plotMultiData(relColLegList, titleTemplate, outputTemplate, yLabel, patternMap, params, scale=Decimal(1.0), xRange='*:*', debug=False): """ relColLegList :: [(rel, col, legend)] rel :: Relation col :: str target column name legend :: str legend title in the plot. Each legend must be unique in the list. params :: [(pattern :: str, mode :: str, bsU :: str, yRange :: str|None)] list of parameters. """ assert(isinstance(relColLegList, list)) assert(isinstance(titleTemplate, str)) assert(isinstance(outputTemplate, str)) assert(isinstance(yLabel, str)) assert(isinstance(patternMap, dict)) assert(isinstance(params, list)) assert(isinstance(scale, Decimal)) assert(isinstance(xRange, str)) assert(isinstance(debug, bool)) if len(params) == 0: raise "params list is empty." for pattern, mode, bsU, yRange in params: title = titleTemplate % (patternMap[pattern], mode, bsU) output = outputTemplate % (pattern, mode, bsU) bsS = str(util.u2s(bsU)) if yRange is None: yRange = '0:*' rp = MultiPlot(relColLegList, pattern, mode, bsS, yLabel, title, output, scale, xRange, yRange, debug) rp.plot() pass
def plotPerformanceData(csvLike, titleTemplate, outputTemplate, targetColumn, yLabel, patternMap, params, scale=Decimal(1.0), xRange='*:*', debug=False): """ params :: [(pattern :: str, bsU :: str, yRange :: str|None)] list of parameters. """ assert (isinstance(csvLike, CsvLike)) assert (isinstance(titleTemplate, str)) assert (isinstance(outputTemplate, str)) assert (isinstance(targetColumn, str)) assert (isinstance(yLabel, str)) assert (isinstance(patternMap, dict)) assert (isinstance(params, list)) assert (isinstance(scale, Decimal)) assert (isinstance(xRange, str)) assert (isinstance(debug, bool)) for pattern, blockSizeU, yRange in params: title = titleTemplate % (patternMap[pattern], blockSizeU) output = outputTemplate % (pattern, blockSizeU) blockSizeS = str(util.u2s(blockSizeU)) if yRange is None: yRange = '0:*' rp = PerformancePlot(csvLike, pattern, blockSizeS, targetColumn, yLabel, title, output, scale, xRange, yRange, debug) rp.plot()
def setBsU(self, bsU): assert(isinstance(bsU, str)) assert(isinstance(util.u2s(bsU), int)) self.__bsU = bsU self.__bs = util.u2s(bsU)
def blockSizeUnitListCheck(self): self.checkParamList('blockSizeUnitList', str) for bsU in self.blockSizeUnitList(): bs = util.u2s(bsU) checkAndThrow(isinstance(bs, int), 'bs must be int.') checkAndThrow(bs > 0, 'bs must > 0.')
for bsU in blockSizeUnitList for nth in nThreadsList for width in widthList] def histogramG(f): for line in f: rec = line.rstrip().split() yield (Decimal(rec[0]), int(rec[1])) for plotDir, outDir in zip(plotDirList, outDirList): if not os.path.exists(outDir): os.makedirs(outDir) for pattern, mode, bsU, nth, width in paramsList: fn = '%s/%s/%s/%s/%s/histogram_%s' % \ (plotDir, pattern, mode, nth, str(util.u2s(bsU)), width) title = 'Histogram with %s %s, blocksize %s, nThreads %s, width %s' % \ (patternMap[pattern], mode, bsU, nth, width) outputFile = outFileTemplate % (pattern, mode, bsU, nth, width) output = "%s/%s" % (outDir, outputFile) f = open(fn) hp = HistogramPlot(histogramG(f), width, title, output, debug=False) hp.plot() f.close() if __name__ == "__main__":
paramsList = [(pattern, mode, bsU, nth, width) for (pattern, mode) in patternModeList for bsU in blockSizeUnitList for nth in nThreadsList for width in widthList] def histogramG(f): for line in f: rec = line.rstrip().split() yield (Decimal(rec[0]), int(rec[1])) for plotDir, outDir in zip(plotDirList, outDirList): if not os.path.exists(outDir): os.makedirs(outDir) for pattern, mode, bsU, nth, width in paramsList: fn = '%s/%s/%s/%s/%s/histogram_%s' % \ (plotDir, pattern, mode, nth, str(util.u2s(bsU)), width) title = 'Histogram with %s %s, blocksize %s, nThreads %s, width %s' % \ (patternMap[pattern], mode, bsU, nth, width) outputFile = outFileTemplate % (pattern, mode, bsU, nth, width) output = "%s/%s" % (outDir, outputFile) f = open(fn) hp = HistogramPlot(histogramG(f), width, title, output, debug=False) hp.plot() f.close() if __name__ == "__main__": doMain()