Ai
3 Star 2 Fork 2

Gitee 极速下载/codis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/CodisLabs/codis
克隆/下载
test_string.go 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
spinlock 提交于 2017-02-08 10:52 +08:00 . extern: using codis-server 3.2.7 as default
// Copyright 2016 CodisLabs. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package main
import (
"flag"
"fmt"
"time"
)
type TestStringTestCase struct {
proxy string
maxlen int
}
func init() {
testcase = &TestStringTestCase{}
}
func (tc *TestStringTestCase) init() {
flag.StringVar(&tc.proxy, "proxy", "", "redis# host:port")
flag.IntVar(&tc.maxlen, "maxlen", 10000, "# bytes of test string")
}
func (tc *TestStringTestCase) main() {
c := NewConn(tc.proxy)
defer c.Close()
u := NewUnit(fmt.Sprintf("test_string_tag{%s}", NewZeroTag()))
u.Del(c, false)
r := &Rand{time.Now().UnixNano()}
n := 0
if step := tc.maxlen / 1000; step != 0 {
buf := make([]byte, step)
for i := 0; i < 1000; i++ {
for j := 0; j < step; j++ {
buf[j] = byte(uint64(r.Next())%(127-32) + 32)
}
u.Append(c, string(buf))
u.GetString(c)
n += step
ops.Incr()
}
}
for ; n < tc.maxlen; n++ {
u.Append(c, string(byte(uint64(r.Next())%(127-32)+32)))
u.GetString(c)
ops.Incr()
}
u.Del(c, true)
fmt.Println("done")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/codis.git
git@gitee.com:mirrors/codis.git
mirrors
codis
codis
de1ad026e329

搜索帮助