mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 12:42:41 +00:00
improved performance test
This commit is contained in:
2
Makefile
2
Makefile
@@ -67,7 +67,7 @@ manpage: $(VENV)
|
||||
|
||||
.PHONY: benchmark
|
||||
benchmark: $(VENV)
|
||||
$(BIN)/pytest --no-cov -rP tests/benchmark.py
|
||||
$(BIN)/pytest --no-cov -s -rP tests/benchmark.py
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
|
||||
@@ -5,10 +5,12 @@ from blag.blag import build
|
||||
|
||||
|
||||
def test_performance(args) -> None:
|
||||
# create 1000 random markdown files in the content directory
|
||||
FILES = 1000
|
||||
print(f"Generating {FILES} files")
|
||||
# create random markdown files in the content directory
|
||||
with open(os.path.join(blag.__path__[0], "content", "testpage.md")) as fh:
|
||||
markdown = fh.read()
|
||||
for i in range(10000):
|
||||
for i in range(FILES):
|
||||
with open(f"content/{i}.md", "w") as f:
|
||||
f.write(markdown)
|
||||
f.write(str(i))
|
||||
@@ -17,14 +19,13 @@ def test_performance(args) -> None:
|
||||
|
||||
t = time()
|
||||
build(args)
|
||||
print(time() - t)
|
||||
|
||||
import cProfile
|
||||
t_first = time() - t
|
||||
print(t_first)
|
||||
|
||||
t = time()
|
||||
#cProfile.run("build(args)")
|
||||
build(args)
|
||||
print(time() - t)
|
||||
t_second = time() - t
|
||||
print(t_second)
|
||||
print(f"First run: {t_first:.2f}s, second run: {t_second:.2f}s")
|
||||
print(f"Speedup: {t_first/t_second:.2f}")
|
||||
|
||||
|
||||
1 / 0
|
||||
|
||||
Reference in New Issue
Block a user