Skip to content

Commit 2f89938

Browse files
committed
docs: update benchmarks
1 parent ee24366 commit 2f89938

File tree

2 files changed

+38
-34
lines changed

2 files changed

+38
-34
lines changed

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,39 +78,39 @@ collection.
7878

7979
| Op | ns/op (collection vs lo ×) | allocs/op (collection vs lo) |
8080
|----|------------------|--------------------|
81-
| All | 231ns / 230ns (1.00x) | 0 / 0 |
82-
| Any | 232ns / 231ns (1.00x) | 0 / 0 |
83-
| Chunk | 127ns / 1.0µs (**8.25x**) | 1 / 51 |
84-
| Contains | 234ns / 231ns (0.99x) | 0 / 0 |
85-
| CountBy | 8.5µs / 8.1µs (0.95x) | 5 / 11 |
86-
| CountByValue | 8.5µs / 8.4µs (0.98x) | 5 / 11 |
87-
| Difference | 19.6µs / 44.0µs (**2.24x**) | 12 / 43 |
88-
| Each | 230ns / 230ns (1.00x) | 0 / 0 |
89-
| Filter | 651ns / 1.1µs (**1.64x**) | 0 / 1 |
90-
| Find | 232ns / 232ns (1.00x) | 0 / 0 |
81+
| All | 237ns / 237ns (≈) | 0 / 0 |
82+
| Any | 232ns / 233ns (≈) | 0 / 0 |
83+
| Chunk | 127ns / 1.1µs (**8.28x**) | 1 / 51 |
84+
| Contains | 234ns / 234ns (≈) | 0 / 0 |
85+
| CountBy | 8.6µs / 8.7µs (≈) | 5 / 11 |
86+
| CountByValue | 8.5µs / 8.1µs (≈) | 5 / 11 |
87+
| Difference | 19.3µs / 43.9µs (**2.27x**) | 12 / 43 |
88+
| Each | 233ns / 231ns (≈) | 0 / 0 |
89+
| Filter | 652ns / 1.1µs (**1.67x**) | 0 / 1 |
90+
| Find | 238ns / 233ns (≈) | 0 / 0 |
9191
| First | 0ns / 0ns (∞) | 0 / 0 |
92-
| GroupBySlice | 8.1µs / 8.3µs (**1.03x**) | 83 / 83 |
93-
| IndexWhere | 243ns / 233ns (0.96x) | 0 / 0 |
94-
| Intersect | 17.3µs / 10.8µs (0.62x) | 12 / 19 |
92+
| GroupBySlice | 8.2µs / 8.3µs () | 83 / 83 |
93+
| IndexWhere | 236ns / 233ns () | 0 / 0 |
94+
| Intersect | 17.1µs / 10.9µs (0.64x) | 12 / 19 |
9595
| Last | 0ns / 0ns (∞) | 0 / 0 |
96-
| Map | 349ns / 811ns (**2.32x**) | 0 / 1 |
97-
| Max | 230ns / 229ns (1.00x) | 0 / 0 |
98-
| Min | 230ns / 231ns (**1.00x**) | 0 / 0 |
99-
| None | 231ns / 231ns (1.00x) | 0 / 0 |
100-
| Pipeline F→M→T→R | 491ns / 1.3µs (**2.63x**) | 0 / 2 |
101-
| Reduce (sum) | 231ns / 230ns (1.00x) | 0 / 0 |
102-
| Reverse | 212ns / 230ns (**1.08x**) | 0 / 0 |
103-
| Shuffle | 3.5µs / 5.3µs (**1.51x**) | 0 / 0 |
104-
| Skip | 0ns / 712ns (∞) | 0 / 1 |
105-
| SkipLast | 0ns / 712ns (∞) | 0 / 1 |
106-
| Sum | 234ns / 230ns (0.98x) | 0 / 0 |
96+
| Map | 349ns / 821ns (**2.35x**) | 0 / 1 |
97+
| Max | 231ns / 231ns (≈) | 0 / 0 |
98+
| Min | 234ns / 232ns (≈) | 0 / 0 |
99+
| None | 232ns / 237ns (≈) | 0 / 0 |
100+
| Pipeline F→M→T→R | 480ns / 1.3µs (**2.73x**) | 0 / 2 |
101+
| Reduce (sum) | 231ns / 230ns () | 0 / 0 |
102+
| Reverse | 214ns / 234ns (**1.09x**) | 0 / 0 |
103+
| Shuffle | 3.6µs / 5.4µs (**1.50x**) | 0 / 0 |
104+
| Skip | 0ns / 722ns (∞) | 0 / 1 |
105+
| SkipLast | 0ns / 715ns (∞) | 0 / 1 |
106+
| Sum | 232ns / 232ns (≈) | 0 / 0 |
107107
| Take | 0ns / 0ns (∞) | 0 / 0 |
108-
| ToMap | 7.6µs / 8.3µs (**1.08x**) | 5 / 6 |
109-
| Union | 17.2µs / 17.8µs (**1.04x**) | 11 / 10 |
110-
| Unique | 6.4µs / 6.3µs (0.99x) | 6 / 6 |
111-
| UniqueBy | 6.7µs / 6.4µs (0.96x) | 7 / 6 |
108+
| ToMap | 7.7µs / 7.9µs (≈) | 5 / 6 |
109+
| Union | 17.5µs / 18.0µs (≈) | 11 / 10 |
110+
| Unique | 6.3µs / 6.3µs () | 6 / 6 |
111+
| UniqueBy | 6.6µs / 6.4µs () | 7 / 6 |
112112
| Zip | 1.4µs / 3.2µs (**2.27x**) | 1 / 1 |
113-
| ZipWith | 985ns / 3.0µs (**3.00x**) | 1 / 1 |
113+
| ZipWith | 978ns / 3.3µs (**3.33x**) | 1 / 1 |
114114
<!-- bench:embed:end -->
115115

116116
## Design Principles

docs/bench/main.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ func renderTable(results []benchResult) string {
697697

698698
var buf bytes.Buffer
699699
buf.WriteString("### Performance Benchmarks\n\n")
700-
buf.WriteString("| Op | ns/op (collection vs lo ×) | allocs/op (collection vs lo) |\n")
701-
buf.WriteString("|----|------------------|--------------------|\n")
700+
buf.WriteString("| Op | ns/op (collection vs lo) | collection vs lo × | allocs/op (collection vs lo) |\n")
701+
buf.WriteString("|----|--------------------------|-------------------|-------------------------------|\n")
702702

703703
names := make([]string, 0, len(byName))
704704
for name := range byName {
@@ -711,18 +711,19 @@ func renderTable(results []benchResult) string {
711711
loRes := byName[name]["lo"]
712712

713713
nsCell := fmt.Sprintf(
714-
"%s / %s (%s)",
714+
"%s / %s",
715715
formatNs(col.nsPerOp),
716716
formatNs(loRes.nsPerOp),
717-
formatRatio(loRes.nsPerOp, col.nsPerOp),
718717
)
718+
ratioCell := formatRatio(loRes.nsPerOp, col.nsPerOp)
719719

720720
allocCell := fmt.Sprintf("%d / %d", col.allocsPerOp, loRes.allocsPerOp)
721721

722722
buf.WriteString(fmt.Sprintf(
723-
"| %s | %s | %s |\n",
723+
"| %s | %s | %s | %s |\n",
724724
name,
725725
nsCell,
726+
ratioCell,
726727
allocCell,
727728
))
728729
}
@@ -759,6 +760,9 @@ func formatRatio(lo, col float64) string {
759760
return "∞"
760761
}
761762
ratio := lo / col
763+
if ratio >= 0.95 && ratio <= 1.05 {
764+
return "≈"
765+
}
762766
out := fmt.Sprintf("%.2fx", ratio)
763767
if ratio > 1 {
764768
return fmt.Sprintf("**%s**", out)

0 commit comments

Comments
 (0)