Limit dmg and dps over time graphs to not hog resources on weaker machines for too long

This commit is contained in:
DarkPhoenix
2019-05-21 14:37:35 +03:00
parent f5cad33b6c
commit 2adc150811
3 changed files with 16 additions and 6 deletions

View File

@@ -35,10 +35,7 @@ class Graph(metaclass=ABCMeta):
raise NotImplementedError
def _xIter(self, fit, extraData, xRange, xAmount):
rangeLow, rangeHigh = sorted(xRange)
limitLow, limitHigh = self._getXLimits(fit, extraData)
rangeLow = max(limitLow, rangeLow)
rangeHigh = min(limitHigh, rangeHigh)
rangeLow, rangeHigh = self._limitXRange(xRange, fit, extraData)
# Amount is amount of ranges between points here, not amount of points
step = (rangeHigh - rangeLow) / xAmount
if step == 0:
@@ -51,6 +48,13 @@ class Graph(metaclass=ABCMeta):
yield current
current += step
def _limitXRange(self, xRange, fit, extraData):
rangeLow, rangeHigh = sorted(xRange)
limitLow, limitHigh = self._getXLimits(fit, extraData)
rangeLow = max(limitLow, rangeLow)
rangeHigh = min(limitHigh, rangeHigh)
return rangeLow, rangeHigh
def _getXLimits(self, fit, extraData):
return -math.inf, math.inf

View File

@@ -28,7 +28,7 @@ class FitDmgVsTimeGraph(Graph):
def getPlotPoints(self, fit, extraData, xRange, xAmount):
# We deliberately ignore xAmount here to build graph which will reflect
# all steps of building up the damage
minX, maxX = xRange
minX, maxX = self._limitXRange(xRange, fit, extraData)
if fit.ID not in self.cache:
self.__generateCache(fit, maxX)
currentY = None
@@ -80,6 +80,9 @@ class FitDmgVsTimeGraph(Graph):
return 0
return roundToPrec(cache[closestTime], 6)
def _getXLimits(self, fit, extraData):
return 0, 1000
def __generateCache(self, fit, maxTime):
cache = self.cache[fit.ID] = {}

View File

@@ -30,7 +30,7 @@ class FitDpsTimeGraph(Graph):
def getPlotPoints(self, fit, extraData, xRange, xAmount):
# We deliberately ignore xAmount here to build graph which will reflect
# all steps of building up the damage
minX, maxX = xRange
minX, maxX = self._limitXRange(xRange, fit, extraData)
if fit.ID not in self.cache:
self.__generateCache(fit, maxX)
currentY = None
@@ -82,6 +82,9 @@ class FitDpsTimeGraph(Graph):
return 0
return roundToPrec(cache[closestTime], 6)
def _getXLimits(self, fit, extraData):
return 0, 1000
def __generateCache(self, fit, maxTime):
cache = []