Skip to content

Commit 2197581

Browse files
KhaGarmelon
andauthored
chore: add import Lean (cold) benchmark (#14121)
Co-authored-by: Joscha <joscha@plugh.de>
1 parent 0056306 commit 2197581

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

tests/evict.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
3+
import argparse
4+
import glob
5+
import os
6+
import sys
7+
8+
9+
def evict(patterns: list[str]) -> None:
10+
evicted = 0
11+
for pattern in patterns:
12+
for path in glob.glob(pattern, recursive=True):
13+
if not os.path.isfile(path):
14+
continue
15+
fd = os.open(path, os.O_RDONLY)
16+
try:
17+
os.posix_fadvise(fd, 0, 0, os.POSIX_FADV_DONTNEED)
18+
finally:
19+
os.close(fd)
20+
evicted += 1
21+
if evicted == 0:
22+
sys.exit(f"error: evicted no files, globs matched nothing: {patterns}")
23+
24+
25+
if __name__ == "__main__":
26+
parser = argparse.ArgumentParser(description="Evict files from the page cache.")
27+
parser.add_argument(
28+
"globs",
29+
nargs="+",
30+
metavar="GLOB",
31+
help="glob patterns to evict (`**` is recursive)",
32+
)
33+
args = parser.parse_args()
34+
evict(args.globs)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cd ../../src
2+
# Like `import Lean`, but drop the built library files from the page cache first for a cold-cache run.
3+
"$TEST_DIR/evict.py" "$BUILD_DIR/lib/lean/**/*"
4+
"$TEST_DIR/measure.py" -t "$TOPIC" -d -o "$OUT" -- \
5+
lean --setup="$BUILD_DIR/lib/temp/Lean.setup.json" Lean.lean

0 commit comments

Comments
 (0)