Asset Pipeline: Improve Performance #235
@ -96,12 +96,24 @@ class Profiler:
|
||||
if profiles == {}:
|
||||
return
|
||||
for key, value in profiles.items():
|
||||
msg = f"{direction} {key} - {value} seconds {PROFILE_KEYS[key]}"
|
||||
seconds = self.get_non_scientific_number(value)
|
||||
msg = f"{direction} {key} - {seconds} seconds {PROFILE_KEYS[key]}"
|
||||
if key in INFO_KEYS:
|
||||
self._logger.info(msg)
|
||||
else:
|
||||
self._logger.debug(msg)
|
||||
|
||||
def get_non_scientific_number(self, x: float):
|
||||
float_str = f'{x:.64f}'.rstrip('0')
|
||||
|
||||
significant_digits = 0
|
||||
for index, c in enumerate(float_str):
|
||||
if significant_digits == 3:
|
||||
return float_str[:index:]
|
||||
|
||||
if c != "0" and c != ".":
|
||||
significant_digits += 1
|
||||
|
||||
def reset(self):
|
||||
self.pull_profiles = {}
|
||||
self._is_push = False
|
||||
|
Loading…
Reference in New Issue
Block a user