File tree 3 files changed +197
-63
lines changed
3 files changed +197
-63
lines changed Original file line number Diff line number Diff line change @@ -110,11 +110,12 @@ $ go test -v ./_examples/performance_test.go
110
110
111
111
> Environment:R7-5800X CPU @ 3.8GHZ GHZ, 32 GB RAM
112
112
113
- | tests | write time (less is better) | read time (less is better) | mixed-operation time (less is better) |
114
- | -------------| -----------------------------| ----------------------------| ---------------------------------------|
115
- | ** cachego** | ** 965ms** | ** 949ms** | ** 991ms** |
116
- | go-cache | 3216ms | 980ms | 4508ms |
117
- | freeCache | 954ms | 968ms | 987ms |
113
+ | tests | read time (less is better) | write time (less is better) | mixed-operation time (less is better) |
114
+ | -------------| ----------------------------| -----------------------------| ---------------------------------------|
115
+ | ** cachego** | ** 945ms** | ** 942ms** | ** 941ms** |
116
+ | go-cache | 965ms | 3251ms | 4390ms |
117
+ | freeCache | 935ms | 994ms | 1012ms |
118
+ | ECache | 931ms | 1068ms | 1071ms |
118
119
119
120
As you can see, cachego has a high performance in concurrent, but segmented lock mechanism has one-more-time positioning
120
121
operation, so if the price of locking is less than the cost of positioning, this mechanism is dragging. The reading
Original file line number Diff line number Diff line change @@ -109,11 +109,12 @@ $ go test -v ./_examples/performance_test.go
109
109
110
110
> 测试环境:R7-5800X CPU @ 3.8GHZ GHZ,32 GB RAM
111
111
112
- | 测试 | 写入消耗时间 (越小越好) | 读取消耗时间 (越小越好) | 混合操作消耗时间 (越小越好) |
112
+ | 测试 | 读取消耗时间 (越小越好) | 写入消耗时间 (越小越好) | 混合操作消耗时间 (越小越好) |
113
113
| -------------| ---------------| ---------------| -----------------|
114
- | ** cachego** | ** 965ms** | ** 949ms** | ** 991ms** |
115
- | go-cache | 3216ms | 980ms | 4508ms |
116
- | freeCache | 954ms | 968ms | 987ms |
114
+ | ** cachego** | ** 945ms** | ** 942ms** | ** 941ms** |
115
+ | go-cache | 965ms | 3251ms | 4390ms |
116
+ | freeCache | 935ms | 994ms | 1012ms |
117
+ | ECache | 931ms | 1068ms | 1071ms |
117
118
118
119
可以看出,由于使用了分段锁机制,读写性能在并发下依然非常高,但是分段锁会多一次定位的操作,如果加锁的消耗小于定位的消耗,那分段锁就不占优势。 这也是为什么 cachego 在写入性能上比 go-cache
119
120
强一大截,但是读取性能却没强多少的原因。后续会着重优化读取性能!
You can’t perform that action at this time.
0 commit comments