class RateAnalyser(WinAnalyser): def __init__(self): super(RateAnalyser, self).__init__() self.timeAndGold = AnalysisTree(2, WinAnalyser, {1: anyValueTime, 2: anyValueGold}) def analyze(self, data): WinAnalyser.analyze(self, data) timeStep = getTimeSection(data.timeStamp) goldDiff = getGoldSection(data.goldDiff) self.timeAndGold.analyze((goldDiff, timeStep), data) def result(self): timeAndGoldTable = [self.timeAndGold.result(keys) for keys in product(possibleGoldValues, possibleTimeValues)] timeTable = [self.timeAndGold.result(keys) for keys in product((anyValueGold,), possibleTimeValues)] goldTable = [self.timeAndGold.result(keys) for keys in product(possibleGoldValues, (anyValueTime,))] winStatistic = self.timeAndGold.result((anyValueGold, anyValueTime)) return TimeGoldSpread(timeAndGoldTable, timeTable, goldTable, winStatistic)
analysisTree.clear() gc.collect() print('Everthing is saved') def shouldAnalyze(dataSet): return dataSet.itemId in Items.apItemIds and dataSet.eventType == FrameEventType.ITEM_PURCHASED print('Ap item ids: ', Items.apItemIds) with skipCounter: lastTime = time.time() for data in dataSets: if not shouldAnalyze(data): continue if doneCount < skipCounter.object: doneCount += 1 continue analysisTree.analyze(mapDataToKey(data), data) doneCount += 1 oneRuncount += 1 #Increase or decrease this number according to the memory available to you. This is for ~1GiB if oneRuncount > 20000: doPartialSaveAndClear(oneRuncount) oneRuncount = 0 if time.time() - lastTime > 10: print("{0} data sets analyzed".format(doneCount)) lastTime = time.time() doPartialSaveAndClear(oneRuncount) print("All data sets are now analysed") print("Analysis saved to disk")