chainyo commited on
Commit
27ba426
·
1 Parent(s): 1e045d7

add timeit function

Browse files
Files changed (1) hide show
  1. utils.py +23 -0
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