write-benchmark

Writes XCTest performance benchmarks and os_signpost instrumentation for Swift repository operations.

1|Updated Apr 5, 2026
One-click install
npx skills add https://github.com/moolah-rocks/moolah-native --skill write-benchmark-moolah-rocks
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: write-benchmark
Source: https://github.com/moolah-rocks/moolah-native/tree/main/.claude/skills/write-benchmark
Command: npx skills add https://github.com/moolah-rocks/moolah-native --skill write-benchmark-moolah-rocks

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding performance benchmarks to an iOS/macOS codebase requires consistent conventions for data seeding, measurement metrics, iteration counts, and signpost instrumentation. This Skill provides a checklist and template so new benchmarks in MoolahBenchmarks follow the project's established patterns and produce reliable, low-noise measurements. ## Core Features & Use Cases - Benchmark authoring checklist: Guides naming conventions (test<Operation>_<Variant>_<Scale>), fixture-based data seeding with BenchmarkFixtures, and scale tiers (1x and 2x). - Measurement standards: Enforces XCTClockMetric and XCTMemoryMetric with 10 iterations, context resets, async bridging via awaitSync, and dead-code prevention. - Signpost instrumentation: Shows how to add os_signpost begin/end pairs to production code using Signposts.repository, Signposts.sync, and Signposts.balance. - Use Case: You want to measure how fast transaction fetching scales with dataset size. The Skill walks you through creating a TransactionFetchBenchmarks class, seeding fixtures, writing the measure block, and validating results with just benchmark. ## Quick Start Write a benchmark for the transaction fetch operation in MoolahBenchmarks following the project conventions.

Frequently Asked Questions about write-benchmark

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a performance benchmark test in XCTest?▼

Create a class in MoolahBenchmarks importing XCTest, seed data with BenchmarkFixtures in setUpWithError, and use measure(metrics:options:) with XCTClockMetric and XCTMemoryMetric. Set options.iterationCount to 10 and name tests as test<Operation>_<Variant>_<Scale>.

How to measure async Swift repository methods in XCTest benchmarks?▼

Use the awaitSync helper to bridge async repository calls inside the synchronous measure block. Assign results to _ or access .count to prevent dead-code elimination, and reset container.mainContext before fetch benchmarks.

How do I add os_signpost instrumentation to Swift production code?▼

Create an OSSignpostID from the appropriate Signposts log (repository, sync, or balance), call os_signpost(.begin) at method entry, and use defer with os_signpost(.end). Include metadata like record counts for variable-size operations.

Why is my XCTest benchmark showing high variance between runs?▼

Relative standard deviation above 20% indicates noise from non-deterministic work or setup leaking into the measure block. Move seeding to setUpWithError, reset contexts at block start, and wrap tight conversion loops in autoreleasepool.

When should I create a new benchmark class versus adding to an existing one?▼

Search MoolahBenchmarks for the operation name first. If a benchmark class for that operation group already exists, add a new test method to it rather than creating a new file; one class covers one operation group.