Pārlūkot izejas kodu

also build releases when tag with v* is pushed

Rodja Trappe 3 gadi atpakaļ
vecāks
revīzija
391e866c34
1 mainītis faili ar 14 papildinājumiem un 0 dzēšanām
  1. 14 0
      nicegui/helpers.py

+ 14 - 0
nicegui/helpers.py

@@ -0,0 +1,14 @@
+import inspect
+import time
+
+
+def measure(*, reset: bool = False, ms: bool = False):
+    global t
+    if 't' in globals() and not reset:
+        dt = time.time() - t
+        line = inspect.stack()[1][0].f_lineno
+        output = f'{dt * 1000:7.3f} ms' if ms else f'{dt:7.3f} s'
+        print(f'{inspect.stack()[1].filename}:{line}', output, flush=True)
+    if reset:
+        print('------------', flush=True)
+    t = time.time()