Commit graph

3 commits

Author SHA1 Message Date
b04e545d03
test: add comprehensive benchmarks for core functions
Adds performance benchmarks for core collection functions to enable
tracking of performance regressions and optimization opportunities.

Benchmarks added:
- Map: 1000 element transformation
- Reduce: 1000 element sum
- Partition: 1000 element split
- Unique/UniqueInPlace: Comparison with many duplicates
- ParallelMap: Multiple worker counts (1, 2, 4, 8)
- MapVsParallelMap: Direct comparison (10k elements)

Key findings from benchmarks:
- Map: 1363 ns/op, 1 alloc (excellent)
- Reduce: 335 ns/op, 0 allocs (excellent)
- Partition: 3411 ns/op, 2 allocs (good - both slices)
- ParallelMap overhead: ~240x slower for simple operations
- ParallelMap is best for CPU-intensive operations (>1ms per element)

Use cases clarified:
- Regular Map for simple/fast operations
- ParallelMap for expensive operations with 100+ elements
- Optimal workers: 1-4 for most workloads

All tests pass 
Coverage maintained 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 14:27:03 +01:00
106b713cc5
test: add comprehensive edge case tests
Adds extensive edge case tests for core functions to catch
regressions and ensure robust behavior.

Test coverage added:
- Empty slice tests: Filter, Map, Partition, Reduce, Unique, Last
- Single element tests: Filter, Map, Partition, Reduce, Unique, Last
- Large dataset tests: Filter (10k), Map (10k)
- Boundary cases: Partition (all pass/reject), Unique (no dups/all same)

Functions tested:
- Filter: 4 new tests (empty, single, single no match, large)
- Partition: 4 new tests (empty, single, all pass, all reject)
- Last: 2 new tests (empty panic, single element)
- Map: 3 new tests (empty, single, large)
- Unique: 4 new tests (empty, single, no dups, all same)
- Reduce: 2 new tests (empty, single)

Results:
- All 118 tests pass
- Coverage: 98.4% (maintained high coverage)
- Verified panic behavior for edge cases

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 13:57:33 +01:00
Ruidy
fa9989c181 feat: reduce 2021-12-28 19:47:05 -04:00