Limit dmg and dps over time graphs to not hog resources on weaker machines for too long
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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] = {}
|
||||
|
||||
|
||||
@@ -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 = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user