Skip to content

Commit d6b44ba

Browse files
authored
Change default, play around with benchmarking. (#80)
* Change default, play around with benchmarking. * Try a final version of the benchmark. * Adjust docstring. * Might as well continue to print time taken. * Fix running benchmarks in CI. * Try again to not skip in CI. * Adjust threshold. * print only 4 decimal places. * Always run benchmarks.
1 parent f35a80f commit d6b44ba

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

fancylog/fancylog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def start_logging(
3232
write_git=True,
3333
write_cli_args=True,
3434
write_python=True,
35-
write_env_packages=True,
35+
write_env_packages=False,
3636
write_variables=True,
3737
log_to_file=True,
3838
log_to_console=True,

tests/tests/test_benchmarks.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import time
2+
3+
import fancylog
4+
5+
6+
def test_benchmark(tmp_path, capsys):
7+
"""
8+
A very rough benchmark to check for large regressions
9+
in performance. Based on testing on GitHub CI:
10+
Windows test_benchmark 0.026
11+
Ubuntu test_benchmark 0.024
12+
macOS test_benchmark 0.0104
13+
"""
14+
start_time = time.perf_counter()
15+
16+
for _ in range(5):
17+
fancylog.start_logging(
18+
tmp_path,
19+
fancylog,
20+
logger_name="my_logger",
21+
)
22+
23+
time_taken = time.perf_counter() - start_time
24+
25+
capsys.readouterr()
26+
with capsys.disabled():
27+
print(f"`test_benchmark` time taken: {time_taken:.4f}")
28+
29+
assert time_taken < 0.05, "Set up is running slower than expected."

0 commit comments

Comments
 (0)