Spaces:
Runtime error
Runtime error
add timeit function
Browse files
utils.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""⭐ Text Classification with Optimum and ONNXRuntime
|
2 |
+
|
3 |
+
Utils functions.
|
4 |
+
|
5 |
+
Author:
|
6 |
+
- @ChainYo - https://github.com/ChainYo
|
7 |
+
"""
|
8 |
+
|
9 |
+
from time import time
|
10 |
+
|
11 |
+
|
12 |
+
def timeit(func):
|
13 |
+
"""Timeit decorator."""
|
14 |
+
|
15 |
+
def wrapper(*args, **kwargs):
|
16 |
+
"""Wrapper."""
|
17 |
+
start = time()
|
18 |
+
result = func(*args, **kwargs)
|
19 |
+
end = time()
|
20 |
+
print(f"{func.__name__} took {end - start:.2f} seconds.")
|
21 |
+
return result
|
22 |
+
|
23 |
+
return wrapper
|