def main(opts): config = ConfigParser() config.optionxform = str if opts.ini == '': print 'ERROR: You must specify a valid ini file path.' return if not os.path.isfile(opts.ini): print 'ERROR: Specified ini file is not found' return config.read(opts.ini) utils.setOptions(opts.options, config) print utils.showOptions(config, ['General', 'DB', 'Load', 'Query']) # Set logging logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt=utils.DEFAULT_TIMEFORMAT, level=getattr(logging, config.get('General', 'LogLevel'))) if not opts.show: queriermodule = config.get('General', 'Querier') queriername = queriermodule.split('.')[-1] exec 'from ' + queriermodule + ' import ' + queriername querier = getattr(sys.modules[queriermodule], queriername)(config) # Run the queries stats = querier.run() h = ('#Query', 'Points', 'Waste', 'Time', 'CPU', 'MEM') rows = [] for stat in stats: (queryName, qTime, qResult, qCPU, qMEM) = stat if qTime == None or qTime == '-': qTime = '-' else: qTime = '%.2f' % qTime if qCPU == None or qCPU == '-': qCPU = '-' qMEM = '-' else: qCPU = '%.2f' % qCPU qMEM = '%.2f' % qMEM rows.append((str(queryName), str(qResult), '-', qTime, qCPU, qMEM)) outputFile = open(utils.RESULTS_FILE_NAME, 'w') outputFile.write(tabulate(rows, headers=h) + '\n') outputFile.close() logging.info('Check results in ' + os.path.abspath(utils.RESULTS_FILE_NAME))
def main(opts): config = ConfigParser() config.optionxform=str if opts.ini == '': print 'ERROR: You must specify a valid ini file path.' return if not os.path.isfile(opts.ini): print 'ERROR: Specified ini file is not found' return config.read(opts.ini) utils.setOptions(opts.options, config) print utils.showOptions(config, ['General', 'DB', 'Load', 'Query']) # Set logging logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt=utils.DEFAULT_TIMEFORMAT, level=getattr(logging, config.get('General','LogLevel'))) if not opts.show: queriermodule = config.get('General','Querier') queriername = queriermodule.split('.')[-1] exec 'from ' + queriermodule + ' import ' + queriername querier = getattr(sys.modules[queriermodule], queriername)(config) # Run the queries stats = querier.run() h = ('#Query','Points','Waste','Time','CPU','MEM') rows = [] for stat in stats: (queryName, qTime, qResult, qCPU, qMEM) = stat if qTime == None or qTime == '-': qTime = '-' else: qTime = '%.2f'%qTime if qCPU == None or qCPU == '-': qCPU = '-' qMEM = '-' else: qCPU = '%.2f'%qCPU qMEM = '%.2f'%qMEM rows.append((str(queryName),str(qResult),'-',qTime,qCPU,qMEM)) outputFile = open(utils.RESULTS_FILE_NAME,'w') outputFile.write(tabulate(rows, headers=h) + '\n') outputFile.close() logging.info('Check results in ' + os.path.abspath(utils.RESULTS_FILE_NAME))
if lines[0].count('Time') == 0: print 'ERROR: first line must be the header and it must start with Time[s]' if ds == None: ds = lines[0].split() for line in lines[3:]: if line !='': fields = line.split() for i in range(len(fields)): if (i,inputFile) not in d: d[(i,inputFile)] = [] d[(i,inputFile)].append(fields[i]) for i in range(1,len(ds)): for j in range(len(d[(i,inputFile)])): d[(i,inputFile)][j] = float(d[(i,inputFile)][j]) rows = [] h = ['QuUs',] + inputFiles print '\t'.join(h) for i in range(1,len(ds)): es = [str(ds[i]),] for inputFile in inputFiles: es.append('%.03f' % (sum(d[(i,inputFile)]) / len(d[(i,inputFile)]))) rows.append(es) print '\t'.join(es) h = ['QuUs',] + inputFiles print tabulate(rows, headers=h)
line += ' & ' + f r.append(f) rows[pName].append(r) texs[pName] += line + ' \\\\'+ '\n' texs[pName] += '\\hline'+ '\n' for hIndex in range(len(hParams)): (pChar, pKey, pIndex, pName, pType, pExpectEqual) = hParams[hIndex] if includes.count(pChar): if mode == 'tex': cols = [] for i in range(len(h)): cols.append('r') tex = """\\begin{table}[!ht] \\begin{tabular}{|l|""" + '|'.join(cols) + """|} """ + texs[pName] + """ \\end{tabular} \\caption{Comparison of query """ + pName + """ for the different approaches} \\label{tab:quering""" + pName + """} \\end{table} """ print tex.replace('_','\_') elif mode == 'csv': print print ','.join([pName,]+h) for row in rows[pName]: print ','.join(row) else: print print tabulate(rows[pName], headers=[pName,]+h)
] + aux)) + ' \\\\ \n' tex += """ \\hline \\end{tabular} \\caption{Times and sizes of the data loading procedure for the different approaches} \\label{tab:loading} \\end{table} """ if mode == 'tex': print tex.replace('_', '\_') elif mode == 'csv': print ','.join(h) for row in rows: print ','.join(row) else: print tabulate(rows, headers=h) def getStatValue(a, op, s=None): try: if s is None: na = a else: na = a[s] if na.size != 0: if op == 'mean': return '%.2f' % na.mean() elif op == 'min': return '%.2f' % na.min() elif op == 'max': return '%.2f' % na.max()
texs[pName] += '\\hline' + '\n' for hIndex in range(len(hParams)): (pChar, pKey, pIndex, pName, pType, pExpectEqual) = hParams[hIndex] if includes.count(pChar): if mode == 'tex': cols = [] for i in range(len(h)): cols.append('r') tex = """\\begin{table}[!ht] \\begin{tabular}{|l|""" + '|'.join(cols) + """|} """ + texs[pName] + """ \\end{tabular} \\caption{Comparison of query """ + pName + """ for the different approaches} \\label{tab:quering""" + pName + """} \\end{table} """ print tex.replace('_', '\_') elif mode == 'csv': print print ','.join([ pName, ] + h) for row in rows[pName]: print ','.join(row) else: print print tabulate(rows[pName], headers=[ pName, ] + h)