diff options
| author | cirakg <cirakg@cirakg.xyz> | 2026-10-19 15:27:37 +0200 |
|---|---|---|
| committer | cirakg <cirakg@cirakg.xyz> | 2026-10-19 15:27:37 +0200 |
| commit | 8ac04a0c2f5cd949a45866f938bd1aa72fbe56e2 (patch) | |
| tree | 80642928d00ab7ee463032db331f41ffcc7ccb11 /test/BenchTest.mc | |
| parent | dd5d0f68726fe56ee4d199867d414aea81905cc4 (diff) | |
test(storage): cover records, vault, PINs, lockout and migrations
34 new tests (65 per device): round trips per entry type, every tampered
byte, swapped records, the pending queue, the entry cap, a full store at
67 fill levels, the lockout schedule on a fake clock including restarts,
erase, PIN change and reset, auto-lock wiping, and v0 to v1 migration.
Adds an in-memory store with a size limit and storage benchmarks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'test/BenchTest.mc')
| -rw-r--r-- | test/BenchTest.mc | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/test/BenchTest.mc b/test/BenchTest.mc index 7e1f612..df12db1 100644 --- a/test/BenchTest.mc +++ b/test/BenchTest.mc @@ -1,5 +1,5 @@ // Author: cirakg & claude ai -// Summary: Benchmarks of the crypto and OTP primitives; logs BENCH lines for docs/PERFORMANCE.md, never fails. +// Summary: Benchmarks of the crypto, OTP and storage code; logs BENCH lines for docs/PERFORMANCE.md, never fails. // // Simulator timings run on the PC's CPU, so they only compare primitives with // each other (for example how much SHA-512 costs against native SHA-1). @@ -55,6 +55,38 @@ module Bench { SelfTest.run(); } } + + // A vault with 20 OTP entries, for list and open timings. + class VaultCases { + var vault as Vault; + var ids as Array<String>; + + function initialize() { + vault = new Vault(new MemoryBackend(), new FakeTime()); + for (var i = 0; i < 20; i++) { + vault.add(StorageFixtures.totp("Entry " + i)); + } + ids = vault.ids(); + } + + // What the list does on start-up: every header. + function readAllHeaders() as Void { + for (var i = 0; i < ids.size(); i++) { + vault.header(ids[i]); + } + } + + // What showing one code does: decrypt one entry. + function openOne() as Void { + vault.open(ids[0]).wipeSecrets(); + } + + function addOne() as Void { + var e = StorageFixtures.totp("Bench"); + vault.add(e); + vault.remove(e.id); + } + } } (:test) @@ -68,3 +100,12 @@ function benchmarkPrimitives(logger as Test.Logger) as Boolean { Bench.measure(logger, "self_test", 3, c.method(:selfTest)); return true; } + +(:test) +function benchmarkVault(logger as Test.Logger) as Boolean { + var v = new Bench.VaultCases(); + Bench.measure(logger, "vault_20_headers", 5, v.method(:readAllHeaders)); + Bench.measure(logger, "vault_open_entry", 20, v.method(:openOne)); + Bench.measure(logger, "vault_add_remove", 10, v.method(:addOne)); + return true; +} |
