|
@@ -8,8 +8,7 @@ import (
|
|
|
"testing"
|
|
|
"time"
|
|
|
"unsafe"
|
|
|
-
|
|
|
- "qfw/util/redis"
|
|
|
+ //"qfw/util/redis"
|
|
|
)
|
|
|
|
|
|
func TestInit(t *testing.T) {
|
|
@@ -88,65 +87,65 @@ func randStr(n int) string {
|
|
|
return *(*string)(unsafe.Pointer(&b))
|
|
|
}
|
|
|
|
|
|
-func Test_old_redis(t *testing.T) {
|
|
|
- redis.InitRedis("other=127.0.0.1:6379")
|
|
|
- chanKey := make(chan string, 50000)
|
|
|
- go func() {
|
|
|
- for i := 0; i < 2000000; i++ {
|
|
|
- chanKey <- randStr(10)
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- go func() {
|
|
|
- ch := make(chan bool, 30)
|
|
|
- t1 := time.Now().Unix()
|
|
|
- for i := 0; i < 2000000; i++ {
|
|
|
- k := <-chanKey
|
|
|
- ch <- true
|
|
|
- go func() {
|
|
|
- defer func() {
|
|
|
- <-ch
|
|
|
- }()
|
|
|
- redis.Put("other", k, 1, 864000)
|
|
|
- }()
|
|
|
- if i%20000 == 0 {
|
|
|
- log.Println("current:", i)
|
|
|
- }
|
|
|
- }
|
|
|
- log.Println("set", time.Now().Unix()-t1)
|
|
|
- }()
|
|
|
- select {}
|
|
|
-}
|
|
|
-
|
|
|
-func Test_old_redis_get(t *testing.T) {
|
|
|
- redis.InitRedis("other=127.0.0.1:6379")
|
|
|
- chanKey := make(chan string, 50000)
|
|
|
- go func() {
|
|
|
- for i := 0; i < 100000; i++ {
|
|
|
- chanKey <- randStr(10)
|
|
|
- }
|
|
|
- }()
|
|
|
-
|
|
|
- go func() {
|
|
|
- ch := make(chan bool, 10)
|
|
|
- t1 := time.Now().Unix()
|
|
|
- for i := 0; i < 100000; i++ {
|
|
|
- k := <-chanKey
|
|
|
- ch <- true
|
|
|
- go func() {
|
|
|
- defer func() {
|
|
|
- <-ch
|
|
|
- }()
|
|
|
- redis.Get("other", k)
|
|
|
- }()
|
|
|
- if i%20000 == 0 {
|
|
|
- log.Println("current:", i)
|
|
|
- }
|
|
|
- }
|
|
|
- log.Println("get", time.Now().Unix()-t1)
|
|
|
- }()
|
|
|
- select {}
|
|
|
-}
|
|
|
+// func Test_old_redis(t *testing.T) {
|
|
|
+// redis.InitRedis("other=127.0.0.1:6379")
|
|
|
+// chanKey := make(chan string, 50000)
|
|
|
+// go func() {
|
|
|
+// for i := 0; i < 2000000; i++ {
|
|
|
+// chanKey <- randStr(10)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+
|
|
|
+// go func() {
|
|
|
+// ch := make(chan bool, 30)
|
|
|
+// t1 := time.Now().Unix()
|
|
|
+// for i := 0; i < 2000000; i++ {
|
|
|
+// k := <-chanKey
|
|
|
+// ch <- true
|
|
|
+// go func() {
|
|
|
+// defer func() {
|
|
|
+// <-ch
|
|
|
+// }()
|
|
|
+// redis.Put("other", k, 1, 864000)
|
|
|
+// }()
|
|
|
+// if i%20000 == 0 {
|
|
|
+// log.Println("current:", i)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// log.Println("set", time.Now().Unix()-t1)
|
|
|
+// }()
|
|
|
+// select {}
|
|
|
+// }
|
|
|
+
|
|
|
+// func Test_old_redis_get(t *testing.T) {
|
|
|
+// redis.InitRedis("other=127.0.0.1:6379")
|
|
|
+// chanKey := make(chan string, 50000)
|
|
|
+// go func() {
|
|
|
+// for i := 0; i < 100000; i++ {
|
|
|
+// chanKey <- randStr(10)
|
|
|
+// }
|
|
|
+// }()
|
|
|
+
|
|
|
+// go func() {
|
|
|
+// ch := make(chan bool, 10)
|
|
|
+// t1 := time.Now().Unix()
|
|
|
+// for i := 0; i < 100000; i++ {
|
|
|
+// k := <-chanKey
|
|
|
+// ch <- true
|
|
|
+// go func() {
|
|
|
+// defer func() {
|
|
|
+// <-ch
|
|
|
+// }()
|
|
|
+// redis.Get("other", k)
|
|
|
+// }()
|
|
|
+// if i%20000 == 0 {
|
|
|
+// log.Println("current:", i)
|
|
|
+// }
|
|
|
+// }
|
|
|
+// log.Println("get", time.Now().Unix()-t1)
|
|
|
+// }()
|
|
|
+// select {}
|
|
|
+// }
|
|
|
|
|
|
func Test_new_redis(t *testing.T) {
|
|
|
r1 := &GoRedis{}
|