Spaces:
Sleeping
Sleeping
| # -*- coding: UTF-8 -*- | |
| """ | |
| @Time : 28/05/2025 16:17 | |
| @Author : xiaoguangliang | |
| @File : utils.py | |
| @Project : Faice_text2face | |
| """ | |
| import time | |
| from contextlib import contextmanager | |
| def timer(msg="all tasks"): | |
| """ | |
| Calculate the time of running | |
| @return: | |
| """ | |
| startTime = time.time() | |
| yield | |
| endTime = time.time() | |
| # print(f'The time cost for {msg}:{round(1000.0 * (endTime - startTime), 2)}, ms') | |
| print(f"The time cost for {msg}:", round((endTime - startTime) / 60, 2), "minutes") | |