[24] fix timing

This commit is contained in:
meisnate12 2022-04-21 14:24:56 -04:00
parent 776bbda4dc
commit cae5bf95b9
4 changed files with 25 additions and 17 deletions

View file

@ -1 +1 @@
1.16.5-develop23 1.16.5-develop24

View file

@ -149,8 +149,7 @@ class Overlays:
logger.separator(f"Applying Overlays for the {self.library.name} Library") logger.separator(f"Applying Overlays for the {self.library.name} Library")
logger.info("") logger.info("")
for i, (over_key, (item, over_names)) in enumerate(sorted(key_to_overlays.items(), key=lambda io: io[1][0].titleSort), 1): for i, (over_key, (item, over_names)) in enumerate(sorted(key_to_overlays.items(), key=lambda io: io[1][0].titleSort), 1):
start_time = time.time() util.check_time("Overlay Start Time")
logger.info(f"Overlay Start Time: {start_time}")
try: try:
logger.ghost(f"Overlaying: {i}/{len(key_to_overlays)} {item.title}") logger.ghost(f"Overlaying: {i}/{len(key_to_overlays)} {item.title}")
image_compare = None image_compare = None
@ -208,8 +207,7 @@ class Overlays:
while util.is_locked(backup_image_path): while util.is_locked(backup_image_path):
time.sleep(1) time.sleep(1)
has_original = backup_image_path has_original = backup_image_path
new_time = time.time() - start_time util.check_time("Find Image Time")
logger.info(f"Find Image Time {new_time}")
poster_compare = None poster_compare = None
if poster is None and has_original is None: if poster is None and has_original is None:
@ -217,8 +215,7 @@ class Overlays:
elif changed_image or overlay_change: elif changed_image or overlay_change:
new_poster = Image.open(poster.location if poster else has_original).convert("RGBA") new_poster = Image.open(poster.location if poster else has_original).convert("RGBA")
temp = os.path.join(self.library.overlay_folder, f"temp.png") temp = os.path.join(self.library.overlay_folder, f"temp.png")
new_time = time.time() - new_time util.check_time("Open Image Time")
logger.info(f"Open Image Time {new_time}")
try: try:
blur_num = 0 blur_num = 0
for over_name in over_names: for over_name in over_names:
@ -233,17 +230,13 @@ class Overlays:
new_poster = new_poster.resize(overlay_images[over_name].size, Image.ANTIALIAS) new_poster = new_poster.resize(overlay_images[over_name].size, Image.ANTIALIAS)
new_poster.paste(overlay_images[over_name], (0, 0), overlay_images[over_name]) new_poster.paste(overlay_images[over_name], (0, 0), overlay_images[over_name])
new_poster.save(temp, "PNG") new_poster.save(temp, "PNG")
new_time = time.time() - new_time util.check_time("Overlay and Save Image Time")
logger.info(f"Overlay and Save Image Time {new_time}")
self.library.upload_poster(item, temp) self.library.upload_poster(item, temp)
new_time = time.time() - new_time util.check_time("Upload Image Time")
logger.info(f"Upload Image Time {new_time}")
self.library.edit_tags("label", item, add_tags=["Overlay"], do_print=False) self.library.edit_tags("label", item, add_tags=["Overlay"], do_print=False)
new_time = time.time() - new_time util.check_time("Edit Tag Time")
logger.info(f"Edit Tag Time {new_time}")
self.library.reload(item) self.library.reload(item)
new_time = time.time() - new_time util.check_time("Reload Time")
logger.info(f"Reload Time {new_time}")
poster_compare = poster.compare if poster else item.thumb poster_compare = poster.compare if poster else item.thumb
logger.info(f"Detail: Overlays: {', '.join(over_names)} applied to {item.title}") logger.info(f"Detail: Overlays: {', '.join(over_names)} applied to {item.title}")
except (OSError, BadRequest) as e: except (OSError, BadRequest) as e:
@ -255,5 +248,5 @@ class Overlays:
poster_compare, overlay=','.join(over_names)) poster_compare, overlay=','.join(over_names))
except Failed as e: except Failed as e:
logger.error(e) logger.error(e)
logger.info(f"Overall Overlay Time {time.time() - start_time}") util.check_time("Overall Overlay Time", end=True)
logger.exorcise() logger.exorcise()

View file

@ -83,6 +83,8 @@ collection_mode_options = {
"show_items": "showItems", "showitems": "showItems" "show_items": "showItems", "showitems": "showItems"
} }
github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/" github_base = "https://raw.githubusercontent.com/meisnate12/Plex-Meta-Manager-Configs/master/"
previous_time = None
start_time = None
def tab_new_lines(data): def tab_new_lines(data):
return str(data).replace("\n", "\n ") if "\n" in str(data) else str(data) return str(data).replace("\n", "\n ") if "\n" in str(data) else str(data)
@ -622,3 +624,16 @@ def replace_label(_label, _data):
final_data = _data final_data = _data
return final_data, replaced return final_data, replaced
def check_time(message, end=False):
global previous_time
global start_time
current_time = time.time()
if end:
previous_time = start_time
if previous_time is None:
logger.debug(f"{message}: {current_time}")
start_time = current_time
else:
logger.debug(f"{message}: {current_time - previous_time}")
previous_time = None if end else current_time

View file

@ -289,7 +289,7 @@ def update_libraries(config):
continue continue
logger.info("") logger.info("")
logger.separator(f"Running {metadata_name} Metadata File\n{metadata.path}") logger.separator(f"Running {metadata_name} Metadata File\n{metadata.path}")
if not config.test_mode and not config.resume_from and not collection_only: if not config.test_mode and not config.resume_from and not collection_only and not operations_only and not overlays_only:
try: try:
metadata.update_metadata() metadata.update_metadata()
except Failed as e: except Failed as e: