From 2adc150811ab60640647b5ac8dd18d3decf4efbd Mon Sep 17 00:00:00 2001 From: DarkPhoenix Date: Tue, 21 May 2019 14:37:35 +0300 Subject: [PATCH] Limit dmg and dps over time graphs to not hog resources on weaker machines for too long --- eos/graph/__init__.py | 12 ++++++++---- eos/graph/fitDmgVsTime.py | 5 ++++- eos/graph/fitDpsVsTime.py | 5 ++++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/eos/graph/__init__.py b/eos/graph/__init__.py index a17282451..e9a9530e8 100644 --- a/eos/graph/__init__.py +++ b/eos/graph/__init__.py @@ -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 diff --git a/eos/graph/fitDmgVsTime.py b/eos/graph/fitDmgVsTime.py index f6aef52e6..a3fdaaeb9 100644 --- a/eos/graph/fitDmgVsTime.py +++ b/eos/graph/fitDmgVsTime.py @@ -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] = {} diff --git a/eos/graph/fitDpsVsTime.py b/eos/graph/fitDpsVsTime.py index baf78b2a1..bb8d2f443 100644 --- a/eos/graph/fitDpsVsTime.py +++ b/eos/graph/fitDpsVsTime.py @@ -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 = []