Asset Pipeline: Improve Performance #235

Merged
Showing only changes of commit 064a8fe392 - Show all commits

View File

@ -96,12 +96,24 @@ class Profiler:
if profiles == {}: if profiles == {}:
return return
for key, value in profiles.items(): 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: if key in INFO_KEYS:
self._logger.info(msg) self._logger.info(msg)
else: else:
self._logger.debug(msg) 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): def reset(self):
self.pull_profiles = {} self.pull_profiles = {}
self._is_push = False self._is_push = False