Skip to content

Commit

Permalink
feat(waifu.py): Add elapsed time display (#12)
Browse files Browse the repository at this point in the history
Because I meet with this kind of problem today again.
  • Loading branch information
LaoshuBaby committed Nov 21, 2022
1 parent 0e409f4 commit e8f5114
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/kqs/waifu.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from typing import Dict, List
from xml.dom import minidom
from xml.etree import ElementTree as ET
Expand Down Expand Up @@ -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 == ""
):
Expand All @@ -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()
Expand Down

0 comments on commit e8f5114

Please sign in to comment.