forked from CodisLabs/codis
/
extra_del.go
43 lines (37 loc) · 897 Bytes
/
extra_del.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2014 Wandoujia Inc. All Rights Reserved.
// Licensed under the MIT (MIT-LICENSE.txt) license.
package main
import (
"flag"
"fmt"
"time"
)
type ExtraDelTestCase struct {
proxy string
}
func init() {
testcase = &ExtraDelTestCase{}
}
func (tc *ExtraDelTestCase) init() {
flag.StringVar(&tc.proxy, "proxy", "", "redis host:port")
}
func (tc *ExtraDelTestCase) main() {
c := NewConn(tc.proxy)
defer c.Close()
for n := 10; n <= 100*10000; n *= 10 {
us := UnitSlice(make([]*Unit, n))
for i := 0; i < len(us); i++ {
key := fmt.Sprintf("extra_del_%d", i)
us[i] = NewUnit(key)
}
for _, u := range us {
u.Set(c, u.key)
ops.Incr()
}
beg := time.Now().UnixNano()
us.Del(c, true)
avg := float64(time.Now().UnixNano()-beg) / float64(time.Millisecond)
fmt.Printf("n = %-10d %8dms avg=%.2fms\n", n, int64(avg), avg/float64(n))
}
fmt.Println("done")
}