1 Star 0 Fork 0

liushipeng/cache2go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
benchmark_test.go 776 Bytes
一键复制 编辑 原始数据 按行查看 历史
Christian Muehlhaeuser 提交于 2017-01-05 21:27 . Updated copyright headers
/*
* Simple caching library with expiration capabilities
* Copyright (c) 2013-2017, Christian Muehlhaeuser <muesli@gmail.com>
*
* For license see LICENSE.txt
*/
package cache2go
import (
"sync"
"sync/atomic"
"testing"
"time"
)
func BenchmarkNotFoundAdd(b *testing.B) {
table := Cache("testNotFoundAdd")
var finish sync.WaitGroup
var added int32
var idle int32
fn := func(id int) {
for i := 0; i < b.N; i++ {
if table.NotFoundAdd(i, 0, i+id) {
atomic.AddInt32(&added, 1)
} else {
atomic.AddInt32(&idle, 1)
}
time.Sleep(0)
}
finish.Done()
}
finish.Add(10)
go fn(0x0000)
go fn(0x1100)
go fn(0x2200)
go fn(0x3300)
go fn(0x4400)
go fn(0x5500)
go fn(0x6600)
go fn(0x7700)
go fn(0x8800)
go fn(0x9900)
finish.Wait()
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liushipeng/cache2go.git
git@gitee.com:liushipeng/cache2go.git
liushipeng
cache2go
cache2go
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385