Skip to content

Commit 47f1aa2

Browse files
committed
Update benchmark results in README files
- Update benchmark results in main README with latest performance metrics - Update benchmarks README with current numbers - Adjust performance improvement percentages to reflect latest changes
1 parent 0d73029 commit 47f1aa2

File tree

2 files changed

+35
-34
lines changed

2 files changed

+35
-34
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,28 +101,29 @@ Based on all the benchmarks across four different caching libraries:
101101

102102
v2 and v3 use Go generics and achieve significant performance improvements over v1:
103103

104-
- v2 is approximately **38-42% faster** than v1 for basic operations
104+
- v2 is approximately **28-42% faster** than v1 for basic operations
105105
- v3 maintains the performance gains of v2 while being compatible with the Hashicorp `simplelru` interface
106+
- Recent optimizations have improved performance across all versions
106107

107108
#### Performance Comparison
108109

109110
| Operation | v1 | v2 | v3 | Improvement v1→v3 |
110111
|-------------------------|-----------|-----------|-----------|-------------------|
111-
| Random LRU (no expire) | 272.4 ns/op | 160.1 ns/op | 158.1 ns/op | ~42% faster |
112-
| Frequency LRU (no expire) | 261.6 ns/op | 152.8 ns/op | 150.9 ns/op | ~42% faster |
113-
| Random LRU (with expire) | 286.5 ns/op | 177.6 ns/op | 175.3 ns/op | ~39% faster |
114-
| Frequency LRU (with expire) | 279.6 ns/op | 170.3 ns/op | 168.1 ns/op | ~40% faster |
112+
| Random LRU (no expire) | 188.3 ns/op | 127.5 ns/op | 132.3 ns/op | ~30% faster |
113+
| Frequency LRU (no expire) | 180.3 ns/op | 127.4 ns/op | 128.1 ns/op | ~29% faster |
114+
| Random LRU (with expire) | 191.9 ns/op | 129.7 ns/op | 130.7 ns/op | ~32% faster |
115+
| Frequency LRU (with expire) | 181.3 ns/op | 126.7 ns/op | 131.2 ns/op | ~28% faster |
115116

116117
#### Cross-Library Comparison
117118

118119
Recent benchmarks comparing expirable-cache with other popular Go caching libraries:
119120

120121
| Operation | [go-pkgz/expirable-cache](https://github.com/go-pkgz/expirable-cache) | [patrickmn/go-cache](https://github.com/patrickmn/go-cache) | [jellydator/ttlcache](https://github.com/jellydator/ttlcache) | [dgraph-io/ristretto](https://github.com/dgraph-io/ristretto) |
121122
|-----------|-----------------|----------|----------|-----------|
122-
| Set | 69.65 ns/op | 84.63 ns/op | 430.7 ns/op | 793.8 ns/op |
123-
| Get | 78.27 ns/op | 66.29 ns/op | 193.1 ns/op | 82.61 ns/op |
124-
| Set+Get | 67.69 ns/op | 68.97 ns/op | 242.8 ns/op | 197.6 ns/op |
125-
| Real-world scenario | 79.98 ns/op | 70.60 ns/op | 200.0 ns/op | 85.88 ns/op |
123+
| Set | 69.14 ns/op | 82.67 ns/op | 448.8 ns/op | 820.0 ns/op |
124+
| Get | 78.12 ns/op | 63.81 ns/op | 190.9 ns/op | 84.23 ns/op |
125+
| Set+Get | 66.62 ns/op | 67.94 ns/op | 253.9 ns/op | 198.2 ns/op |
126+
| Real-world scenario | 78.83 ns/op | 70.24 ns/op | 198.0 ns/op | 83.40 ns/op |
126127
| Memory allocations | Lowest | Low | Medium | Highest |
127128

128129
<details>

benchmarks/README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@ goos: darwin
1919
goarch: arm64
2020
pkg: github.com/go-pkgz/expirable-cache/benchmarks
2121
cpu: Apple M3
22-
BenchmarkGoCache_Set-8 13150846 84.63 ns/op 68 B/op 1 allocs/op
23-
BenchmarkGoCache_Get-8 17746971 66.29 ns/op 3 B/op 0 allocs/op
24-
BenchmarkGoCache_SetAndGet-8 17334808 68.97 ns/op 36 B/op 1 allocs/op
25-
BenchmarkTTLCache_Set-8 2818526 430.7 ns/op 4 B/op 0 allocs/op
26-
BenchmarkTTLCache_Get-8 6197169 193.1 ns/op 51 B/op 1 allocs/op
27-
BenchmarkTTLCache_SetAndGet-8 4923871 242.8 ns/op 28 B/op 1 allocs/op
28-
BenchmarkExpirableCache_Set-8 17001220 69.65 ns/op 4 B/op 0 allocs/op
29-
BenchmarkExpirableCache_Get-8 15427915 78.27 ns/op 3 B/op 0 allocs/op
30-
BenchmarkExpirableCache_SetAndGet-8 17600006 67.69 ns/op 4 B/op 0 allocs/op
31-
BenchmarkRistretto_Set-8 1502190 793.8 ns/op 262 B/op 5 allocs/op
32-
BenchmarkRistretto_Get-8 14158246 82.61 ns/op 27 B/op 2 allocs/op
33-
BenchmarkRistretto_SetAndGet-8 6852046 197.6 ns/op 96 B/op 2 allocs/op
34-
BenchmarkGoCache_GetWithTypeAssertion-8 17942817 67.64 ns/op 3 B/op 0 allocs/op
35-
BenchmarkTTLCache_GetWithoutTypeAssertion-8 6029751 199.0 ns/op 51 B/op 1 allocs/op
36-
BenchmarkExpirableCache_GetWithoutTypeAssertion-8 15133410 79.33 ns/op 3 B/op 0 allocs/op
37-
BenchmarkRistretto_GetWithTypeAssertion-8 14187883 86.12 ns/op 27 B/op 2 allocs/op
38-
BenchmarkGoCache_RealWorldScenario-8 16314248 70.60 ns/op 4 B/op 0 allocs/op
39-
BenchmarkTTLCache_RealWorldScenario-8 5891400 200.0 ns/op 52 B/op 1 allocs/op
40-
BenchmarkExpirableCache_RealWorldScenario-8 14579878 79.98 ns/op 3 B/op 0 allocs/op
41-
BenchmarkRistretto_RealWorldScenario-8 12897400 85.88 ns/op 28 B/op 2 allocs/op
22+
BenchmarkGoCache_Set-8 12169099 82.67 ns/op 68 B/op 1 allocs/op
23+
BenchmarkGoCache_Get-8 18444500 63.81 ns/op 3 B/op 0 allocs/op
24+
BenchmarkGoCache_SetAndGet-8 17692840 67.94 ns/op 36 B/op 1 allocs/op
25+
BenchmarkTTLCache_Set-8 2707100 448.8 ns/op 5 B/op 0 allocs/op
26+
BenchmarkTTLCache_Get-8 6269760 190.9 ns/op 51 B/op 1 allocs/op
27+
BenchmarkTTLCache_SetAndGet-8 4806730 253.9 ns/op 28 B/op 1 allocs/op
28+
BenchmarkExpirableCache_Set-8 17192541 69.14 ns/op 4 B/op 0 allocs/op
29+
BenchmarkExpirableCache_Get-8 15239731 78.12 ns/op 3 B/op 0 allocs/op
30+
BenchmarkExpirableCache_SetAndGet-8 17954317 66.62 ns/op 4 B/op 0 allocs/op
31+
BenchmarkRistretto_Set-8 1456555 820.0 ns/op 262 B/op 5 allocs/op
32+
BenchmarkRistretto_Get-8 14321246 84.23 ns/op 27 B/op 2 allocs/op
33+
BenchmarkRistretto_SetAndGet-8 5989928 198.2 ns/op 96 B/op 2 allocs/op
34+
BenchmarkGoCache_GetWithTypeAssertion-8 17971783 66.44 ns/op 3 B/op 0 allocs/op
35+
BenchmarkTTLCache_GetWithoutTypeAssertion-8 6114782 197.9 ns/op 51 B/op 1 allocs/op
36+
BenchmarkExpirableCache_GetWithoutTypeAssertion-8 15095240 78.39 ns/op 3 B/op 0 allocs/op
37+
BenchmarkRistretto_GetWithTypeAssertion-8 14458339 83.09 ns/op 27 B/op 2 allocs/op
38+
BenchmarkGoCache_RealWorldScenario-8 16622580 70.24 ns/op 4 B/op 0 allocs/op
39+
BenchmarkTTLCache_RealWorldScenario-8 6038209 198.0 ns/op 52 B/op 1 allocs/op
40+
BenchmarkExpirableCache_RealWorldScenario-8 14718102 78.83 ns/op 3 B/op 0 allocs/op
41+
BenchmarkRistretto_RealWorldScenario-8 13030276 83.40 ns/op 28 B/op 2 allocs/op
4242
```
4343

4444
## Summary of Results
4545

4646
| Operation | [go-pkgz/expirable-cache](https://github.com/go-pkgz/expirable-cache) | [patrickmn/go-cache](https://github.com/patrickmn/go-cache) | [jellydator/ttlcache](https://github.com/jellydator/ttlcache) | [dgraph-io/ristretto](https://github.com/dgraph-io/ristretto) |
4747
|-----------|-----------------|----------|----------|-----------|
48-
| Set | 69.65 ns/op | 84.63 ns/op | 430.7 ns/op | 793.8 ns/op |
49-
| Get | 78.27 ns/op | 66.29 ns/op | 193.1 ns/op | 82.61 ns/op |
50-
| Set+Get | 67.69 ns/op | 68.97 ns/op | 242.8 ns/op | 197.6 ns/op |
51-
| Real-world scenario | 79.98 ns/op | 70.60 ns/op | 200.0 ns/op | 85.88 ns/op |
52-
| Memory allocations (Set) | 4 B/op | 68 B/op | 4 B/op | 262 B/op |
48+
| Set | 69.14 ns/op | 82.67 ns/op | 448.8 ns/op | 820.0 ns/op |
49+
| Get | 78.12 ns/op | 63.81 ns/op | 190.9 ns/op | 84.23 ns/op |
50+
| Set+Get | 66.62 ns/op | 67.94 ns/op | 253.9 ns/op | 198.2 ns/op |
51+
| Real-world scenario | 78.83 ns/op | 70.24 ns/op | 198.0 ns/op | 83.40 ns/op |
52+
| Memory allocations (Set) | 4 B/op | 68 B/op | 5 B/op | 262 B/op |
5353
| Memory allocations (Get) | 3 B/op | 3 B/op | 51 B/op | 27 B/op |
5454

5555
## Analysis

0 commit comments

Comments
 (0)