Compare commits

..
Author SHA1 Message Date
David Peter 0143c9ef2e Describe the Linux cache-clearing example accurately 2026-10-02 11:29:16 +02:00
2 changed files with 17 additions and 8 deletions

No files matched your search

+2 -2
View File
@@ -56,8 +56,8 @@ hyperfine --warmup 3 'grep -R TODO *'
```
Conversely, if you want to run the benchmark for a cold cache, you can use the `-p`/`--prepare`
option to run a special command before *each* timing run. For example, to clear harddisk caches
on Linux, you can run
option to run a special command before *each* timing run. For example, to clear Linux filesystem caches,
you can run
```sh
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
```
+15 -6
View File
@@ -4,14 +4,23 @@ This folder contains scripts that can be used in combination with hyperfines `--
```bash
hyperfine 'sleep 0.020' 'sleep 0.021' 'sleep 0.022' --export-json sleep.json
uv run plot_whisker.py sleep.json
./plot_whisker.py sleep.json
```
### Pre-requisites
Install [`uv`](https://docs.astral.sh/uv/getting-started/installation/) and run the
commands above from this directory.
To make these scripts work, you will need `numpy`, `matplotlib` and `scipy`.
The scripts declare their dependencies using [PEP 723](https://peps.python.org/pep-0723/)
inline script metadata. `uv run` automatically installs these dependencies in an
isolated environment before running the script.
If you have a Python package manager that understands [PEP-723](https://peps.python.org/pep-0723/)
inline script requirements like [`uv`](https://github.com/astral-sh/uv) or [`pipx`](https://github.com/pypa/pipx),
you can directly run the scripts using
```bash
uv run plot_whisker.py sleep.json
```
Otherwise, install the dependencies via your system package manager or using `pip`:
```bash
pip install numpy matplotlib scipy # pip3, if you are using python3
```