mini-diarium / benchmarks
CLAUDE.md318 starsChanged 12 days agoMITView on GitHub
Performance benchmarks for Mini Diarium. Two layers: Rust hot-path benchmarks (criterion 0.5) and frontend render benchmarks (Vitest bench). Rust benchmarks live in src-tauri/benches/ (four criterion files: auth, cipher, db, word count). Frontend benchmark: src/lib/markdown.bench.ts. Dashboard report page: benchmarks/index.html (served from gh-pages). For the canonical post-task checklist (tests + formatting + CHANGELOG + TODO), see Post-Task Completion Best Practices. Benchmark-specific: The bench files themselves are the inventory — read cipher_bench.rs, db_bench.rs, auth_bench.rs, word_count_bench.rs (criterion) and markdown.bench.ts (Vitest) for the current scenario…
In this repository49 other files it gives its agents.
- .agents/skills/unsafe-checker/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- e2e/CLAUDE.mdCLAUDE.md
- src/CLAUDE.mdCLAUDE.md
- src-tauri/CLAUDE.mdCLAUDE.md
- website/CLAUDE.mdCLAUDE.md
- website/llms-full.txtllms.txt
- website/llms.txtllms.txt
- ci-gate-diagnosisSkill
- coding-guidelinesSkill
- domain-webSkill
- exploration-modeSkill
- flathub-maintenanceSkill
- m01-ownershipSkill
- m02-resourceSkill
- m03-mutabilitySkill
- m04-zero-costSkill
- m05-type-drivenSkill
- m06-error-handlingSkill
- m07-concurrencySkill
- m09-domainSkill
- m10-performanceSkill
- m11-ecosystemSkill
- m12-lifecycleSkill
- m13-domain-errorSkill
- m14-mental-modelSkill
- m15-anti-patternSkill
- manual-planningSkill
- runbooksSkill
- rust-call-graphSkill
- rust-code-navigatorSkill
- rust-dailySkill
- rust-deps-visualizerSkill
- rust-learnerSkill
- rust-refactor-helperSkill
- rust-skill-creatorSkill
- rust-symbol-analyzerSkill
- rust-trait-explorerSkill
- security-stanceSkill
- seo-auditSkill
- seo-performance-reviewSkill
- skill-improverSkill
- solidjsSkill
- sync-lockfilesSkill
- tauri-agent-devSkill
- tauri-v2Skill
- tiptapSkill
- todo-managerSkill
- unsafe-checkerSkill
The file
We split this CLAUDE.md into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
All threshold values are stored in nanoseconds inside index.html as a THRESHOLDS object keyed by benchmark name.
- Distinctive: line 44
When adding a new benchmark:
- Very specific: line 45
Add it to the SECTIONS array (for grouping).
- Very specific: line 46
Add a META entry (title, description, interpretation).
- Very specific: line 47
Add a THRESHOLDS entry with target and critical values in nanoseconds.
- Very specific: line 60
After each run, the workflow also copies benchmarks/index.html to gh-pages so the custom report reflects the latest data.
- Very specific: line 89
Do not increase sample_size on this group.
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Benchmarks — CLAUDE.md
Performance benchmarks for Mini Diarium. Two layers: Rust hot-path benchmarks (criterion 0.5) and frontend render benchmarks (Vitest bench).
Rust benchmarks live in src-tauri/benches/ (four criterion files: auth, cipher, db, word count). Frontend benchmark: src/lib/markdown.bench.ts. Dashboard report page: benchmarks/index.html (served from gh-pages).
Verification Commands
For the canonical post-task checklist (tests + formatting + CHANGELOG + TODO), see Post-Task Completion Best Practices.
Benchmark-specific:
| Command | What it does |
cargo bench --manifest-path src-tauri/Cargo.toml | Run all Rust benchmarks |
cargo bench --manifest-path src-tauri/Cargo.toml --bench cipher_bench | Run cipher benchmarks only |
cargo bench --manifest-path src-tauri/Cargo.toml -- --output-format html | HTML report → target/criterion/ (workspace target dir at repo root) |
bun run bench | Run frontend Vitest benchmarks |
Benchmarks Covered
The bench files themselves are the inventory — read cipher_bench.rs, db_bench.rs, auth_bench.rs, word_count_bench.rs (criterion) and markdown.bench.ts (Vitest) for the current scenario list. ci_pipeline_duration is workflow-generated, not a bench file.
Two design choices that the bench code does not explain:
- The
db_*benches use an in-memory DB on purpose — it isolates query CPU cost from disk-flush variance. db_search_entries/3650(decade scale) is the architecture decision gate: 150 ms. If the in-memory scan exceeds it, the no-plaintext-index design has to be revisited.
Benchmark Dashboard (index.html)
The custom report page is a single static HTML file served from the gh-pages branch. It has no build step — all dependencies (Chart.js, chartjs-plugin-annotation) are loaded from CDN.
Visual features
- Threshold lines: Horizontal reference lines on each chart showing target (green), warning (amber, 1.5× target), and critical (red, 2× target) performance envelopes. Rendered via
chartjs-plugin-annotation. - SMA trendline: Simple moving average overlay (orange dashed) to smooth CI runner noise and reveal long-term drift. Window auto-scales: 3 for 6–15 points, 5 for 16–30, 7 for >30.
- Regression highlighting: Cards with the latest value above warning get an amber border + "⚠ Above target" badge; above critical gets a red border + "🔴 Critical" badge.
- Toggle controls: "Show trendline" and "Show thresholds" checkboxes in the page header.
THRESHOLDS constant
All threshold values are stored in nanoseconds inside index.html as a THRESHOLDS object keyed by benchmark name. All benchmarks that appear in data.js have thresholds (Rust benchmarks + the synthetic ci_pipeline_duration). The warning level is not stored — it is derived as target * 1.5 at render time.
When adding a new benchmark:
- Add it to the
SECTIONSarray (for grouping). - Add a
METAentry (title, description, interpretation). - Add a
THRESHOLDSentry withtargetandcriticalvalues in nanoseconds.
Auth threshold gap
Auth benchmarks only have upper-bound thresholds. A value dropping below expected (faster Argon2id) is equally dangerous (weakened KDF parameters) but is not shown on the dashboard. This is mitigated by CI (which alerts on slowdowns) and a dedicated unit test checking minimum Argon2 parameters.
CI Integration
Workflow: .github/workflows/benchmark.yml
Trigger: every push to master
Results: stored as JSON in gh-pages branch under benchmarks/
Alert threshold: 200% — posts a PR comment if a benchmark regresses to 2× but does not fail the CI job.
After each run, the workflow also copies benchmarks/index.html to gh-pages so the custom report reflects the latest data.
contents: write permission is required on the workflow to push results to gh-pages.
CI Pipeline Duration Metric
A synthetic benchmark named ci_pipeline_duration is computed by the workflow itself (not by Cargo/bencher).
It measures total wall-clock time from workflow start to the end of the benchmark job, covering lint, test, build, and e2e stages.
The value is appended to bench-output.txt in bencher format (<name> <value> nanoseconds) so it integrates with the existing github-action-benchmark storage and appears in data.js.
On the dashboard it is rendered in the "CI Pipeline" section with a target threshold of 600 s and critical at 1 200 s.
The duration step uses if: always() so it runs even after earlier steps fail. However, the subsequent "Store benchmark results" step does not use if: always() — so a ci_pipeline_duration data point is only pushed when the full Rust bench job succeeds. Failed runs do not record a duration metric.
Gotchas
harness = falseis required — bench targets declarecriterion_main!themselves; settingharness = falsein[[bench]]prevents Cargo from injecting the default test harness. Without it, compilation fails with duplicatemainsymbols.- Cold-target compile time — the first
cargo benchrun compiles criterion and all bench targets from scratch. Expect 2–5 minutes. Subsequent runs are incremental. - CI numbers ≠ developer numbers — GitHub Actions shared runners have variable CPU performance. Absolute numbers are not meaningful; only the trend over time matters.
jsdomenvironment is required formarkdown.bench.ts— DOMPurify callswindow.document.createElement. Vitest's defaultjsdomenvironment (set invitest.config.ts) provides this. Do not add a@vitest-environmentoverride — it would be redundant and could cause confusion.- Keep
NamedTempFilealive initer_batchedsetups —tempfile::NamedTempFiledeletes its file onDrop. Initer_batched, the setup closure must return both(tmp, db)so the file outlives the benchmark iteration. Droppingtmpbefore the iteration runs will cause SQLite to open a deleted file. Exception: the three mutating benches (db_insert_entry,db_update_entry,db_delete_entry) now usecreate_database(":memory:", …)and carry no tempfile, so this rule no longer applies to them — it still governs the read/search benches that seed a file-backed DB. - All benchmark imports use
mini_diarium_lib::*— the app crate's Cargo.toml[lib]section declaresname = "mini_diarium_lib". Benchmark targets (which stay insrc-tauri/benches/, built with the app crate) import from this crate name, not from the binary target. Sincedbmoved to themini-diarium-corecrate andcrypto/authmoved further to themini-diarium-cryptocrate (open-core M1 then M3a),lib.rsre-exports them (pub use mini_diarium_core::{auth, crypto, db, …};, and core in turn re-exportscrypto/authfrom the crypto crate), somini_diarium_lib::{crypto,auth,db}::…bench imports resolve unchanged through the two-hop re-export.db_benchalso reachesmini_diarium_lib::commands::search(an app-crate module). All three crates set[lib] bench = false. - Auth bench uses
sample_size(10)intentionally — Argon2id takes 100–300 ms per sample; 10 samples (~30–60 s) is sufficient for trend tracking without blocking CI. Do not increasesample_sizeon this group. - Auth bench alerts on slowdowns only — criterion tracks regressions (things getting slower). It does NOT alert if Argon2id gets faster/weaker (e.g. reduced iterations). Guarding against weakened parameters requires a dedicated unit test checking minimum param values — that is a separate concern from performance benchmarking.
parseMarkdownToHtmlbenchmarks do not appear on the dashboard — they are frontend Vitest benchmarks not run in CI. Only the 18 Rust benchmarks are indata.jsand rendered on the report page. Do not add them toSECTIONSorTHRESHOLDSunless the CI workflow is also updated to run and store frontend results.- Threshold values are initial estimates — they are calibrated from interpretation text and domain knowledge, not from actual CI data. Once real data flows, review and tighten/relax as needed.
chartjs-plugin-annotationmust match Chart.js v4 — the report page loadschartjs-plugin-annotation@3which is the major version compatible with Chart.js 4. Do not upgrade one without the other.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

