def processErrors(errList): errLimitList = [0.1,0.2,0.3,0.4,0.5,1,2,3,4,5,8,10,12,15] csvHeader = list() csvHeader.append("numberIterationErrors") csvHeader.append("maxRelativeError") csvHeader.append("minRelativeError") csvHeader.append("averageRelativeError") for errLimit in errLimitList: csvHeader.append("numberErrorsLessThan"+str(errLimit)) csvOutDict = dict() csvOutDict["numberIterationErrors"]=len(errList) for errLimit in errLimitList: (maxRelErr, minRelErr, avgRelErr, relErrLowerLimit, errListFiltered) = parseUtils.relativeErrorParser(errList, errLimit) csvOutDict["maxRelativeError"] = maxRelErr csvOutDict["minRelativeError"] = minRelErr csvOutDict["averageRelativeError"] = avgRelErr csvOutDict["numberErrorsLessThan"+str(errLimit)] = relErrLowerLimit # Write info to csv file csvFullPath = "out.csv" if not os.path.isfile(csvFullPath): csvWFP = open(csvFullPath, "a") writer = csv.writer(csvWFP, delimiter=';') writer.writerow(csvHeader) else: csvWFP = open(csvFullPath, "a") writer = csv.writer(csvWFP, delimiter=';') row = list() for item in csvHeader: if item in csvOutDict: row.append(csvOutDict[item]) else: row.append(" ") writer.writerow(row) csvWFP.close()
def processErrors(benchmarkname_machinename, sdcItemList, threadIdx, threadTotals, errLimitList): benchmark = benchmarkname_machinename machine = benchmarkname_machinename m = re.match("(.*)_(.*)", benchmarkname_machinename) if m: benchmark = m.group(1) machine = m.group(2) benchmark = benchmark.strip() machine = machine.strip() if not parseErrorUtils.hasParser(benchmark): #print benchmark+" - There is no parser implemented" return sdci = 1 total_sdcs = len(sdcItemList) csvHeader = list() csvHeader.append("logFileName") csvHeader.append("machine") csvHeader.append("benchmark") csvHeader.append("header") csvHeader.append("sdcIteration") csvHeader.append("numberAccumulatedErrors") csvHeader.append("numberIterationErrors") csvHeader.append("numberIterationErrorsLogged") csvHeader.append("numberIterationErrorsParsed") csvHeader.append("maxRelativeError") csvHeader.append("minRelativeError") csvHeader.append("averageRelativeError") for errLimit in errLimitList: csvHeader.append("numberErrorsLessThan" + str(errLimit)) csvHeader.append("localityForErrorsHigherThan" + str(errLimit)) csvHeader.append("numberZeroOutput") csvHeader.append("numberZeroGold") for sdcItem in sdcItemList: progress = "{0:.2f}".format(sdci / total_sdcs * 100) threadsOutput[threadIdx] = "[ " + benchmark + " " + str( sdci) + "/" + str(total_sdcs) + "] " output = "" for i in range(0, numThreads): output += threadsOutput[i] sys.stdout.write("\r" + output) sys.stdout.flush() logFileName = sdcItem[0] header = sdcItem[1] header = header.strip() header = re.sub(r"[^\w]", '-', header) #keep only numbers and digits header = header.strip() sdcIteration = sdcItem[2] iteErrors = sdcItem[3] accIteErrors = sdcItem[4] errList = sdcItem[5] # csvOutDict = dict() # csvOutDict["logFileName"] = logFileName # csvOutDict["machine"] = machine # csvOutDict["benchmark"] = benchmark # csvOutDict["header"] = header # csvOutDict["sdcIteration"] = sdcIteration # csvOutDict["numberAccumulatedErrors"] = accIteErrors # csvOutDict["numberIterationErrors"] = iteErrors key = benchmarkname_machinename + "_" + header if (not key in threadTotals): threadTotals[key] = dict() threadTotals[key]["errors"] = 0.0 for errLimit in errLimitList: threadTotals[key][str(errLimit)] = 0.0 logFileNameNoExt = logFileName m = re.match("(.*).log", logFileName) if m: logFileNameNoExt = m.group(1) # csvOutDict["numberIterationErrorsLogged"] = len(errList) errorsParsed = parseErrorUtils.parseErrors(errList, benchmark, header) if errorsParsed is None: sdci += 1 continue # csvOutDict["numberIterationErrorsParsed"] = len(errorsParsed) # (csvOutDict["numberZeroOutput"], csvOutDict["numberZeroGold"] ) = parseUtils.countZerosReadExpected(errorsParsed) (maxRelErr, minRelErr, avgRelErr, relErrLowerLimit, errListFiltered) = parseUtils.relativeErrorParser( errorsParsed, 0.0) totErrors = len(errListFiltered) if (totErrors > 0): threadTotals[key]["errors"] += 1.0 for errLimit in errLimitList: (maxRelErr, minRelErr, avgRelErr, relErrLowerLimit, errListFiltered) = parseUtils.relativeErrorParser( errorsParsed, errLimit) # csvOutDict["maxRelativeError"] = maxRelErr # csvOutDict["minRelativeError"] = minRelErr # csvOutDict["averageRelativeError"] = avgRelErr # csvOutDict["numberErrorsLessThan"+str(errLimit)] = relErrLowerLimit # csvOutDict["localityForErrorsHigherThan"+str(errLimit)] = parseUtils.localityMultiDimensional(errListFiltered) if (relErrLowerLimit == totErrors): threadTotals[key][str(errLimit)] += 1 elif (relErrLowerLimit > totErrors): print("wtf:" + str(relErrLowerLimit) + ">" + str(totErrors)) # Write info to csv file # csvFileName = "logs_parsed_machine-"+machine+"_benchmark-"+benchmark+"_header-"+header+".csv" # csvFullPath = os.path.join(csvDirOut, csvFileName) # if not os.path.exists(os.path.dirname(csvFullPath)): # try: # os.makedirs(os.path.dirname(csvFullPath)) # except OSError as exc: # Guard against race condition # if exc.errno != errno.EEXIST: # raise # if not os.path.isfile(csvFullPath): # csvWFP = open(csvFullPath, "a") # writer = csv.writer(csvWFP, delimiter=';') # writer.writerow(csvHeader) # else: # csvWFP = open(csvFullPath, "a") # writer = csv.writer(csvWFP, delimiter=';') # row = list() # for item in csvHeader: # if item in csvOutDict: # row.append(csvOutDict[item]) # else: # row.append(" ") # writer.writerow(row) # # csvWFP.close() sdci += 1