You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(differ): add comprehensive benchmark suite for differ package (#23)
* feat(differ): add comprehensive benchmark suite for differ package
Add benchmark tests for differ package with 10 benchmarks covering all
major operations and performance patterns. Update documentation to
reflect new benchmarks and performance metrics.
Changes:
- Add differ/differ_bench_test.go with 10 comprehensive benchmarks
- Convenience functions (Diff, DiffParsed)
- Struct-based API (Differ.Diff, Differ.DiffParsed)
- Different modes (Simple, Breaking)
- Configuration options (WithInfo, WithoutInfo)
- Edge cases (IdenticalSpecs)
- Parse-once pattern efficiency
- Update benchmarks.md with differ performance metrics
- Add Differ Performance section with detailed results
- Update benchmark count from 60+ to 70+
- Update version from v1.7.0 to v1.9.1 in overview
- Add differ to benchmark suite listing
- Add differ to running benchmarks examples
- Update best practices to include differ
- Update README.md with differ benchmarks
- Update benchmark count from 60+ to 70+
- Update version from v1.7.0 to v1.9.1
- Add 58x faster DiffParsed performance metric
- Add Diff operation to performance table
- Update Makefile with differ support
- Add bench-differ target for running differ benchmarks
- Add ./differ to all benchmark targets (bench, bench-save,
bench-baseline, bench-cpu, bench-mem, bench-profile)
- Add bench-differ to .PHONY targets
Performance Results:
- DiffParsed is 58x faster than Diff (7.8μs vs 457μs)
- Identical specs comparison is very fast (2.8μs) - fast path working
- Breaking mode vs Simple mode has negligible difference (~0.15μs)
This update completes the benchmark coverage for all five core packages
(parser, validator, converter, joiner, differ).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* fix(differ): update benchmarks to use Go 1.24+ for b.Loop() pattern
Address claude-review feedback by updating all differ benchmarks to use
the modern Go 1.24+ for b.Loop() pattern for consistency with other
packages. Also add comprehensive benchmark testing guidance to CLAUDE.md.
Changes:
- Update all 10 benchmarks to use for b.Loop() instead of the old
for i := 0; i < b.N; i++ pattern
- Remove redundant b.ReportAllocs() calls (handled by b.Loop())
- Remove unnecessary b.ResetTimer() calls for trivial setup
- Add package-level comment about b.Fatalf usage pattern
- Add new "Benchmark Test Requirements" section to CLAUDE.md
- Document the for b.Loop() pattern as the required standard
- Provide correct and incorrect examples
- Explain why consistency matters
- Add guidance on when to include setup outside the loop
This ensures consistency across all five benchmark files:
- parser/parser_bench_test.go: Uses for b.Loop() ✅
- validator/validator_bench_test.go: Uses for b.Loop() ✅
- converter/converter_bench_test.go: Uses for b.Loop() ✅
- joiner/joiner_bench_test.go: Uses for b.Loop() ✅
- differ/differ_bench_test.go: Now uses for b.Loop() ✅
Benchmark results remain consistent with previous run, confirming the
pattern change has no negative impact on performance measurement.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
---------
Co-authored-by: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,14 +166,15 @@ See [pkg.go.dev](https://pkg.go.dev/github.com/erraggy/oastools) for complete AP
166
166
167
167
## Benchmarks
168
168
169
-
The library includes comprehensive performance benchmarking (60+ benchmarks across all packages). As of v1.7.0, significant optimizations have been implemented:
169
+
The library includes comprehensive performance benchmarking (70+ benchmarks across all packages). As of v1.9.1, significant optimizations have been implemented:
Copy file name to clipboardExpand all lines: benchmarks.md
+43-4Lines changed: 43 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This document provides detailed performance analysis and benchmark results for t
4
4
5
5
## Overview
6
6
7
-
As of v1.7.0, oastools includes comprehensive performance benchmarking infrastructure covering all major operations across the parser, validator, converter, and joiner packages. The library has undergone targeted optimizations to achieve significant performance improvements while maintaining correctness and code quality.
7
+
As of v1.9.1, oastools includes comprehensive performance benchmarking infrastructure covering all major operations across the parser, validator, converter, joiner, and differ packages. The library has undergone targeted optimizations to achieve significant performance improvements while maintaining correctness and code quality.
8
8
9
9
**Platform**: Apple M4, darwin/arm64, Go 1.24
10
10
@@ -35,7 +35,7 @@ The v1.7.0 release includes a major optimization to JSON marshaling that elimina
35
35
36
36
## Benchmark Suite
37
37
38
-
The benchmark suite includes **60+ benchmarks** across four main packages:
38
+
The benchmark suite includes **70+ benchmarks** across five main packages:
39
39
40
40
### Parser Package (32 benchmarks)
41
41
@@ -84,6 +84,16 @@ The benchmark suite includes **60+ benchmarks** across four main packages:
84
84
- Array merge strategies
85
85
- Tag deduplication
86
86
87
+
### Differ Package (10 benchmarks)
88
+
89
+
**Diffing Operations**:
90
+
- Diff (parse + diff) vs DiffParsed (pre-parsed)
91
+
- Simple mode vs Breaking mode
92
+
- Convenience functions (Diff, DiffParsed) vs struct-based API
93
+
- Configuration options (IncludeInfo)
94
+
- Edge cases (identical specifications)
95
+
- Parse-once pattern efficiency
96
+
87
97
## Current Performance Metrics
88
98
89
99
### Parser Performance
@@ -178,16 +188,43 @@ The benchmark suite includes **60+ benchmarks** across four main packages:
178
188
179
189
**Observation**: JoinParsed is **154x faster** than Join for 2 small documents (747ns vs 115μs) because it skips parsing. The actual joining operation has minimal overhead.
**Observation**: DiffParsed is **58x faster** than Diff (7.8μs vs 457μs) because it skips parsing. The differ includes a fast path for identical specifications that runs in ~2.8μs. Breaking mode vs Simple mode has negligible performance difference (~0.15μs), making breaking change detection essentially free.
216
+
181
217
## Performance Best Practices
182
218
183
219
### For Library Users
184
220
185
-
1.**Reuse parser/validator/converter/joiner instances** when processing multiple files with the same configuration
186
-
2.**Use ParseOnce workflows**: For operations on the same document (validate, convert, join), parse once and pass the `ParseResult` to subsequent operations:
221
+
1.**Reuse parser/validator/converter/joiner/differ instances** when processing multiple files with the same configuration
222
+
2.**Use ParseOnce workflows**: For operations on the same document (validate, convert, join, diff), parse once and pass the `ParseResult` to subsequent operations:
0 commit comments