diff options
| author | eunhhu <[email protected]> | 2026-10-04 21:36:04 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-04 21:36:04 +0100 |
| commit | 85a57b8eb2704565ef646f2415eedcd1386a4afd (patch) | |
| tree | 5a0879a50a8c0098e6bc0e1fd93fa2f518f475a4 /research/experiments/036-faster-loops/bfscount.py | |
| parent | e8bc8ddd8f64e2f923eee86dd3624689bbd30241 (diff) | |
| download | pure-85a57b8eb2704565ef646f2415eedcd1386a4afd.tar.gz pure-85a57b8eb2704565ef646f2415eedcd1386a4afd.zip | |
Measure computing faster: a search 2.1 times as fast, TPC-C 4.1%, four fingers found and undone (121)
Diffstat (limited to 'research/experiments/036-faster-loops/bfscount.py')
| -rw-r--r-- | research/experiments/036-faster-loops/bfscount.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/research/experiments/036-faster-loops/bfscount.py b/research/experiments/036-faster-loops/bfscount.py new file mode 100644 index 0000000..234a24f --- /dev/null +++ b/research/experiments/036-faster-loops/bfscount.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 +"""A search's user-mode instructions and cycles, core only (research 121): +each bfs-run (BFS_WAIT) loads the graph, then 025's pcount (built in +PCOUNT_DIR from 025's pcount.c) counts its seven searches. + +bfscount.py PCOUNT_DIR BFS_RUN... (the graph: ~/.cache/pure-036/graph.pmod, runs.sh build) +""" +import subprocess, sys, os, json +SP = sys.argv[1] +for binary in sys.argv[2:]: + env = dict(os.environ, BFS_WAIT='1') + p = subprocess.Popen([binary, os.path.expanduser('~/.cache/pure-036/graph.pmod'), '100000', '1000000', '7'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env, text=True) + assert p.stderr.readline().strip() == 'loaded' + c = subprocess.Popen([f'{SP}/pcount', str(p.pid)], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) + assert c.stderr.readline().strip() == 'ready' + p.stdin.write('\n'); p.stdin.flush() + out = p.stdout.read().strip().splitlines()[-1]; p.wait() + counts = json.loads(c.communicate('')[0]) + print(binary.split('/')[-2], out, {k: round(v / 7 / 1e6, 2) for k, v in counts.items()}, 'M per search') |
