Skip to content

Commit

Permalink
Debug benchmark workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
shBLOCK committed May 11, 2024
1 parent 04a3437 commit 98b5a3b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion benchmark/benchmarking.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def __init__(self):
import platform, cpuinfo, os
self.system = platform.system()
log(f"System: {self.system}")
self.ci = os.getenv("CI") == "true"
self.ci = CI
log(f"CI: {self.ci}")
try:
cpu = cpuinfo.get_cpu_info()
Expand Down
20 changes: 13 additions & 7 deletions benchmark/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gc
import os
import inspect
import itertools
from contextlib import contextmanager
Expand All @@ -11,7 +12,10 @@
import colorama
from numerize.numerize import numerize

CI = os.getenv("CI") == "true"

__all__ = (
"CI",
"SourceLines",
"indent",
"dedent",
Expand Down Expand Up @@ -106,26 +110,28 @@ def indent_log(n=1):
assert _log_indent >= 0

_log_chrs_stack = []
_log_temp_log = False
@contextmanager
def temp_log(disable=False):
if disable:
yield
return

global _should_indent
global _should_indent, _log_temp_log
_log_temp_log = True
old_should_indent = _should_indent
_log_chrs_stack.append(0)
yield
# print("\\b"+str(_log_chrs_stack[-1]))
# print(colorama.ansi.clear_line(1), end="")
# print(colorama.ansi.Cursor.UP())
# print("\r", end="", flush=True)
print("\r\033[K", end="", flush=True)
# print("\b" * _log_chrs_stack.pop(-1), end="")
if not CI:
print("\b" * _log_chrs_stack.pop(-1), end="")
_should_indent = old_should_indent
_log_temp_log = False

_should_indent = True
def log(msg="", new_line=True, color: str = None):
if CI and _log_temp_log:
return

global _should_indent
msg = str(msg)
if _should_indent:
Expand Down

0 comments on commit 98b5a3b

Please sign in to comment.