1- //nolint:errcheck
21package cache_test
32
43import (
@@ -12,7 +11,7 @@ import (
1211 "github.com/android-sms-gateway/server/pkg/cache"
1312)
1413
15- // BenchmarkMemoryCache_Set measures the performance of Set operations
14+ // BenchmarkMemoryCache_Set measures the performance of Set operations.
1615func BenchmarkMemoryCache_Set (b * testing.B ) {
1716 cache := cache .NewMemory (0 )
1817 ctx := context .Background ()
@@ -27,7 +26,7 @@ func BenchmarkMemoryCache_Set(b *testing.B) {
2726 })
2827}
2928
30- // BenchmarkMemoryCache_Get measures the performance of Get operations
29+ // BenchmarkMemoryCache_Get measures the performance of Get operations.
3130func BenchmarkMemoryCache_Get (b * testing.B ) {
3231 cache := cache .NewMemory (0 )
3332 ctx := context .Background ()
@@ -45,7 +44,7 @@ func BenchmarkMemoryCache_Get(b *testing.B) {
4544 })
4645}
4746
48- // BenchmarkMemoryCache_SetAndGet measures the performance of Set followed by Get
47+ // BenchmarkMemoryCache_SetAndGet measures the performance of Set followed by Get.
4948func BenchmarkMemoryCache_SetAndGet (b * testing.B ) {
5049 cache := cache .NewMemory (0 )
5150 ctx := context .Background ()
@@ -64,7 +63,7 @@ func BenchmarkMemoryCache_SetAndGet(b *testing.B) {
6463 })
6564}
6665
67- // BenchmarkMemoryCache_SetOrFail measures the performance of SetOrFail operations
66+ // BenchmarkMemoryCache_SetOrFail measures the performance of SetOrFail operations.
6867func BenchmarkMemoryCache_SetOrFail (b * testing.B ) {
6968 cache := cache .NewMemory (0 )
7069 ctx := context .Background ()
@@ -79,7 +78,7 @@ func BenchmarkMemoryCache_SetOrFail(b *testing.B) {
7978 })
8079}
8180
82- // BenchmarkMemoryCache_GetAndDelete measures the performance of GetAndDelete operations
81+ // BenchmarkMemoryCache_GetAndDelete measures the performance of GetAndDelete operations.
8382func BenchmarkMemoryCache_GetAndDelete (b * testing.B ) {
8483 cache := cache .NewMemory (0 )
8584 ctx := context .Background ()
@@ -98,7 +97,7 @@ func BenchmarkMemoryCache_GetAndDelete(b *testing.B) {
9897 })
9998}
10099
101- // BenchmarkMemoryCache_Delete measures the performance of Delete operations
100+ // BenchmarkMemoryCache_Delete measures the performance of Delete operations.
102101func BenchmarkMemoryCache_Delete (b * testing.B ) {
103102 cache := cache .NewMemory (0 )
104103 ctx := context .Background ()
@@ -117,7 +116,7 @@ func BenchmarkMemoryCache_Delete(b *testing.B) {
117116 })
118117}
119118
120- // BenchmarkMemoryCache_Cleanup measures the performance of Cleanup operations
119+ // BenchmarkMemoryCache_Cleanup measures the performance of Cleanup operations.
121120func BenchmarkMemoryCache_Cleanup (b * testing.B ) {
122121 cache := cache .NewMemory (0 )
123122 ctx := context .Background ()
@@ -137,7 +136,7 @@ func BenchmarkMemoryCache_Cleanup(b *testing.B) {
137136 })
138137}
139138
140- // BenchmarkMemoryCache_Drain measures the performance of Drain operations
139+ // BenchmarkMemoryCache_Drain measures the performance of Drain operations.
141140func BenchmarkMemoryCache_Drain (b * testing.B ) {
142141 cache := cache .NewMemory (0 )
143142 ctx := context .Background ()
@@ -157,7 +156,7 @@ func BenchmarkMemoryCache_Drain(b *testing.B) {
157156 })
158157}
159158
160- // BenchmarkMemoryCache_ConcurrentReads measures performance with different numbers of concurrent readers
159+ // BenchmarkMemoryCache_ConcurrentReads measures performance with different numbers of concurrent readers.
161160func BenchmarkMemoryCache_ConcurrentReads (b * testing.B ) {
162161 cache := cache .NewMemory (0 )
163162 ctx := context .Background ()
@@ -190,7 +189,7 @@ func BenchmarkMemoryCache_ConcurrentReads(b *testing.B) {
190189 }
191190}
192191
193- // BenchmarkMemoryCache_ConcurrentWrites measures performance with different numbers of concurrent writers
192+ // BenchmarkMemoryCache_ConcurrentWrites measures performance with different numbers of concurrent writers.
194193func BenchmarkMemoryCache_ConcurrentWrites (b * testing.B ) {
195194 cache := cache .NewMemory (0 )
196195 ctx := context .Background ()
@@ -223,7 +222,7 @@ func BenchmarkMemoryCache_ConcurrentWrites(b *testing.B) {
223222 }
224223}
225224
226- // BenchmarkMemoryCache_MixedWorkload measures performance with mixed read/write operations
225+ // BenchmarkMemoryCache_MixedWorkload measures performance with mixed read/write operations.
227226func BenchmarkMemoryCache_MixedWorkload (b * testing.B ) {
228227 cache := cache .NewMemory (0 )
229228 ctx := context .Background ()
@@ -265,7 +264,7 @@ func BenchmarkMemoryCache_MixedWorkload(b *testing.B) {
265264 }
266265}
267266
268- // BenchmarkMemoryCache_Scaling measures how performance scales with increasing load
267+ // BenchmarkMemoryCache_Scaling measures how performance scales with increasing load.
269268func BenchmarkMemoryCache_Scaling (b * testing.B ) {
270269 cache := cache .NewMemory (0 )
271270 ctx := context .Background ()
@@ -284,7 +283,7 @@ func BenchmarkMemoryCache_Scaling(b *testing.B) {
284283 for _ , bm := range benchmarks {
285284 b .Run (bm .name , func (b * testing.B ) {
286285 // Pre-populate cache
287- for i := 0 ; i < bm .operationsPerGoroutine * bm .goroutines ; i ++ {
286+ for i := range bm .operationsPerGoroutine * bm .goroutines {
288287 key := "key-" + strconv .Itoa (i )
289288 value := "value-" + strconv .Itoa (i )
290289 cache .Set (ctx , key , []byte (value ))
@@ -305,7 +304,7 @@ func BenchmarkMemoryCache_Scaling(b *testing.B) {
305304 }
306305}
307306
308- // BenchmarkMemoryCache_TTLOverhead measures the performance impact of TTL operations
307+ // BenchmarkMemoryCache_TTLOverhead measures the performance impact of TTL operations.
309308func BenchmarkMemoryCache_TTLOverhead (b * testing.B ) {
310309 c := cache .NewMemory (0 )
311310 ctx := context .Background ()
@@ -337,7 +336,7 @@ func BenchmarkMemoryCache_TTLOverhead(b *testing.B) {
337336 }
338337}
339338
340- // BenchmarkMemoryCache_LargeValues measures performance with large values
339+ // BenchmarkMemoryCache_LargeValues measures performance with large values.
341340func BenchmarkMemoryCache_LargeValues (b * testing.B ) {
342341 cache := cache .NewMemory (0 )
343342 ctx := context .Background ()
@@ -375,7 +374,7 @@ func BenchmarkMemoryCache_LargeValues(b *testing.B) {
375374 }
376375}
377376
378- // BenchmarkMemoryCache_MemoryGrowth measures memory allocation patterns
377+ // BenchmarkMemoryCache_MemoryGrowth measures memory allocation patterns.
379378func BenchmarkMemoryCache_MemoryGrowth (b * testing.B ) {
380379 cache := cache .NewMemory (0 )
381380 ctx := context .Background ()
@@ -402,7 +401,7 @@ func BenchmarkMemoryCache_MemoryGrowth(b *testing.B) {
402401 }
403402}
404403
405- // BenchmarkMemoryCache_RandomAccess measures performance with random key access patterns
404+ // BenchmarkMemoryCache_RandomAccess measures performance with random key access patterns.
406405func BenchmarkMemoryCache_RandomAccess (b * testing.B ) {
407406 cache := cache .NewMemory (0 )
408407 ctx := context .Background ()
@@ -426,7 +425,7 @@ func BenchmarkMemoryCache_RandomAccess(b *testing.B) {
426425 })
427426}
428427
429- // BenchmarkMemoryCache_HotKey measures performance with a frequently accessed key
428+ // BenchmarkMemoryCache_HotKey measures performance with a frequently accessed key.
430429func BenchmarkMemoryCache_HotKey (b * testing.B ) {
431430 cache := cache .NewMemory (0 )
432431 ctx := context .Background ()
@@ -444,14 +443,14 @@ func BenchmarkMemoryCache_HotKey(b *testing.B) {
444443 })
445444}
446445
447- // BenchmarkMemoryCache_ColdKey measures performance with rarely accessed keys
446+ // BenchmarkMemoryCache_ColdKey measures performance with rarely accessed keys.
448447func BenchmarkMemoryCache_ColdKey (b * testing.B ) {
449448 cache := cache .NewMemory (0 )
450449 ctx := context .Background ()
451450 const numKeys = 10000
452451
453452 // Pre-populate cache with many keys
454- for i := 0 ; i < numKeys ; i ++ {
453+ for i := range numKeys {
455454 key := "key-" + strconv .Itoa (i )
456455 value := "value-" + strconv .Itoa (i )
457456 cache .Set (ctx , key , []byte (value ))
0 commit comments