From e8f511443167e0112bb99a49960f9a6177b5db72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=AB=E4=B9=90=E7=9A=84=E8=80=81=E9=BC=A0=E5=AE=9D?= =?UTF-8?q?=E5=AE=9D?= Date: Tue, 22 Nov 2022 03:13:26 +0800 Subject: [PATCH] feat(waifu.py): Add elapsed time display (#12) Because I meet with this kind of problem today again. --- src/kqs/waifu.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kqs/waifu.py b/src/kqs/waifu.py index 5e1240c..e9ebfe6 100644 --- a/src/kqs/waifu.py +++ b/src/kqs/waifu.py @@ -1,3 +1,4 @@ +import time from typing import Dict, List from xml.dom import minidom from xml.etree import ElementTree as ET @@ -116,6 +117,8 @@ def pre_read_warn(mode: str, file_path: str, text: str, url: str): 'WARN:"text" is not standard Keqing read mode, it caughted by fallback system and recognized as "memory"' ) + time_start = time.time() + if mode == "file" or ( (mode == "memory" or mode == "text") and text == "" ): @@ -140,6 +143,9 @@ def pre_read_warn(mode: str, file_path: str, text: str, url: str): else: raise TypeError(f"Unexpected read mode: {mode}") + time_end = time.time() + print("[TIME]: " + str(round((time_end - time_start), 3)) + "s" + "\n") + def read_file(self, file_path: str): tree: ElementTree = ET.parse(file_path) root: Element = tree.getroot()