@@ -1425,9 +1425,17 @@ func TestSerializeUnserializable(t *testing.T) {
1425
1425
}
1426
1426
}
1427
1427
1428
- func BenchmarkCacheGet (b * testing.B ) {
1428
+ func BenchmarkCacheGetExpiring (b * testing.B ) {
1429
+ benchmarkCacheGet (b , 5 * time .Minute )
1430
+ }
1431
+
1432
+ func BenchmarkCacheGetNotExpiring (b * testing.B ) {
1433
+ benchmarkCacheGet (b , NoExpiration )
1434
+ }
1435
+
1436
+ func benchmarkCacheGet (b * testing.B , exp time.Duration ) {
1429
1437
b .StopTimer ()
1430
- tc := New (DefaultExpiration , 0 )
1438
+ tc := New (exp , 0 )
1431
1439
tc .Set ("foo" , "bar" , DefaultExpiration )
1432
1440
b .StartTimer ()
1433
1441
for i := 0 ; i < b .N ; i ++ {
@@ -1449,9 +1457,17 @@ func BenchmarkRWMutexMapGet(b *testing.B) {
1449
1457
}
1450
1458
}
1451
1459
1452
- func BenchmarkCacheGetConcurrent (b * testing.B ) {
1460
+ func BenchmarkCacheGetConcurrentExpiring (b * testing.B ) {
1461
+ benchmarkCacheGetConcurrent (b , 5 * time .Minute )
1462
+ }
1463
+
1464
+ func BenchmarkCacheGetConcurrentNotExpiring (b * testing.B ) {
1465
+ benchmarkCacheGetConcurrent (b , NoExpiration )
1466
+ }
1467
+
1468
+ func benchmarkCacheGetConcurrent (b * testing.B , exp time.Duration ) {
1453
1469
b .StopTimer ()
1454
- tc := New (DefaultExpiration , 0 )
1470
+ tc := New (exp , 0 )
1455
1471
tc .Set ("foo" , "bar" , DefaultExpiration )
1456
1472
wg := new (sync.WaitGroup )
1457
1473
workers := runtime .NumCPU ()
@@ -1493,13 +1509,21 @@ func BenchmarkRWMutexMapGetConcurrent(b *testing.B) {
1493
1509
wg .Wait ()
1494
1510
}
1495
1511
1496
- func BenchmarkCacheGetManyConcurrent (b * testing.B ) {
1512
+ func BenchmarkCacheGetManyConcurrentExpiring (b * testing.B ) {
1513
+ benchmarkCacheGetManyConcurrent (b , 5 * time .Minute )
1514
+ }
1515
+
1516
+ func BenchmarkCacheGetManyConcurrentNotExpiring (b * testing.B ) {
1517
+ benchmarkCacheGetManyConcurrent (b , NoExpiration )
1518
+ }
1519
+
1520
+ func benchmarkCacheGetManyConcurrent (b * testing.B , exp time.Duration ) {
1497
1521
// This is the same as BenchmarkCacheGetConcurrent, but its result
1498
1522
// can be compared against BenchmarkShardedCacheGetManyConcurrent
1499
1523
// in sharded_test.go.
1500
1524
b .StopTimer ()
1501
1525
n := 10000
1502
- tc := New (DefaultExpiration , 0 )
1526
+ tc := New (exp , 0 )
1503
1527
keys := make ([]string , n )
1504
1528
for i := 0 ; i < n ; i ++ {
1505
1529
k := "foo" + strconv .Itoa (n )
@@ -1521,9 +1545,17 @@ func BenchmarkCacheGetManyConcurrent(b *testing.B) {
1521
1545
wg .Wait ()
1522
1546
}
1523
1547
1524
- func BenchmarkCacheSet (b * testing.B ) {
1548
+ func BenchmarkCacheSetExpiring (b * testing.B ) {
1549
+ benchmarkCacheSet (b , 5 * time .Minute )
1550
+ }
1551
+
1552
+ func BenchmarkCacheSetNotExpiring (b * testing.B ) {
1553
+ benchmarkCacheSet (b , NoExpiration )
1554
+ }
1555
+
1556
+ func benchmarkCacheSet (b * testing.B , exp time.Duration ) {
1525
1557
b .StopTimer ()
1526
- tc := New (DefaultExpiration , 0 )
1558
+ tc := New (exp , 0 )
1527
1559
b .StartTimer ()
1528
1560
for i := 0 ; i < b .N ; i ++ {
1529
1561
tc .Set ("foo" , "bar" , DefaultExpiration )
@@ -1602,7 +1634,7 @@ func BenchmarkIncrementInt(b *testing.B) {
1602
1634
}
1603
1635
}
1604
1636
1605
- func BenchmarkDeleteExpired (b * testing.B ) {
1637
+ func BenchmarkDeleteExpiredLoop (b * testing.B ) {
1606
1638
b .StopTimer ()
1607
1639
tc := New (5 * time .Minute , 0 )
1608
1640
tc .mu .Lock ()
0 commit comments