ktongue commited on
Commit
fa13125
·
verified ·
1 Parent(s): a3e73f8

Upload hf_env/lib/python3.14/site-packages/pip/_vendor/rich/_timer.py with huggingface_hub

Browse files
hf_env/lib/python3.14/site-packages/pip/_vendor/rich/_timer.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Timer context manager, only used in debug.
3
+
4
+ """
5
+
6
+ from time import time
7
+
8
+ import contextlib
9
+ from typing import Generator
10
+
11
+
12
+ @contextlib.contextmanager
13
+ def timer(subject: str = "time") -> Generator[None, None, None]:
14
+ """print the elapsed time. (only used in debugging)"""
15
+ start = time()
16
+ yield
17
+ elapsed = time() - start
18
+ elapsed_ms = elapsed * 1000
19
+ print(f"{subject} elapsed {elapsed_ms:.1f}ms")