Пример #1
0
func main() {
	REDIS_SERVER := "10.10.81.163:6379"
	REDIS_PASSWD := ""
	//	REDIS_SERVER := "127.0.0.1:6379"
	//	REDIS_PASSWD := ""
	pool := createPool(REDIS_SERVER, REDIS_PASSWD)

	setName := "SetTest"
	stF := utee.Tick()
	for i := 0; i < 60; i++ {
		dayValMax := getDay(-1*i, DATE_FORMAT_YmDH)
		dayValMin := getDay(-1*i-1, DATE_FORMAT_YmDH)
		st := utee.Tick()
		i, err := zcount(pool, setName, dayValMin, dayValMax)
		if err != nil {
			fmt.Println("err:", err)
		}
		fmt.Println(" get val range @min:", dayValMin, " @max:", dayValMax, " @count:", i, " @spent:", (utee.Tick() - st))
	}
	fmt.Println(" get val range 60 times eachDayRange @spent:", (utee.Tick() - stF))

	dayValMax := getDay(0, DATE_FORMAT_YmDH)
	dayValMin := getDay(-30, DATE_FORMAT_YmDH)
	stF = utee.Tick()
	count, _ := zcount(pool, setName, dayValMin, dayValMax)
	fmt.Println(" get val range 30 Days @min:", dayValMin, " @max:", dayValMax, " @count:", count, "  @spent:", (utee.Tick() - stF))
	dayValMax = getDay(-9, DATE_FORMAT_YmDH)
	dayValMin = getDay(-16, DATE_FORMAT_YmDH)
	stF = utee.Tick()
	count, _ = zcount(pool, setName, dayValMin, dayValMax)
	fmt.Println(" get val range 7 Days @min:", dayValMin, " @max:", dayValMax, " @count:", count, "  @spent:", (utee.Tick() - stF))
}
Пример #2
0
func main() {
	AddConnector("127.0.0.1:6000", 1)
	AddConnector("127.0.0.2:6000", 1)
	AddConnector("127.0.0.3:6000", 1)
	fmt.Println(c.Members())
	fmt.Println(m)
	PrintMap()
	for i := 0; i < 10; i++ {
		uuid := strconv.Itoa(i)
		RouteAndDispatch(uuid)
	}
	PrintMap()

	for i := 10; i < 100; i++ {
		uuid := strconv.Itoa(i)
		RouteAndDispatch(uuid)
	}
	PrintMap()
	for i := 100; i < 1000; i++ {
		uuid := strconv.Itoa(i)
		RouteAndDispatch(uuid)
	}
	PrintMap()
	for i := 1000; i < 10000; i++ {
		uuid := strconv.Itoa(i)
		RouteAndDispatch(uuid)
	}
	PrintMap()
	for i := 10000; i < 100000; i++ {
		uuid := strconv.Itoa(i)
		RouteAndDispatch(uuid)
	}
	PrintMap()
	RemoveReDispatch("127.0.0.1:6000", 1)
	PrintMap()
	AddReDispatch("127.0.0.1:6000", 1)
	PrintMap()
	t := utee.Tick()
	for i := 100000; i < 200000; i++ {
		uuid := strconv.Itoa(i)
		RouteAndDispatch(uuid)
	}
	fmt.Println("route ", 100000, " spend ", utee.Tick()-t, " msec")
	t = utee.Tick()

	var wg sync.WaitGroup

	route := func(id string) {
		defer wg.Done()
		RouteAndDispatch(id)
	}

	for i := 0; i < 10000000; i++ {
		uuid := strconv.Itoa(i)
		wg.Add(1)
		go route(fmt.Sprint("hello", uuid))
	}
	wg.Wait()
	fmt.Println("route ", 10000000, " spend ", utee.Tick()-t, " msec")
}
Пример #3
0
func main() {
	log.Println("hello")
	t := 10000

	st := utee.Tick()
	for i := 0; i < t; i++ {
		wg.Add(1)
		go test()
	}
	wg.Wait()
	cost := utee.Tick() - st
	log.Println("@times:", t, " invoke cost:", cost, " second")

}
Пример #4
0
func main() {
	var v int
	log.Println(v)
	for i := 0; i < 5; i++ {
		fmt.Println(i)
	}

	t := utee.Tick()
	log.Println("@t:", t)
	buf := bytes.NewBufferString("hello")
	buf.WriteString(" world @time:" + strconv.FormatInt(t, 10))
	log.Println(buf.String())
	if v, e := strconv.Atoi(""); e != nil {
		log.Println("@err:", e, " v:", v)
	} else {
		log.Println(v)
	}

	log.Println(strings.ToUpper("hello world"))
	a := []string{"hello", "world"}
	for i, v := range a {
		log.Println("@i:", i, " @v:", v)
	}
	va := "hi"
	if va == "hi" {
		log.Println("equals is ==")
	}

	s := "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8YmlzUmVzcG9uc2VEVE8+CiAgICA8cmVzcENvZGU+MTAzMDwvcmVzcENvZGU+CiAgICA8cmVzcEluZm8+5pWw5a2X562+5ZCN6ZSZ6K+vPC9yZXNwSW5mbz4KICAgIDxyZXNwVGltZT4xNDQ3MzgyMDU5NjEyPC9yZXNwVGltZT4KPC9iaXNSZXNwb25zZURUTz4K"
	b, e := base64.StdEncoding.DecodeString(s)
	log.Println("@e:", e, "@v:", string(b))
	vs := strconv.Itoa(1024)
	log.Println(vs)
	vi, _ := strconv.Atoi(vs)
	log.Println("@vi+1:", (vi + 1))

	mt, err := strconv.ParseInt("1429345203123", 10, 64)
	log.Println("@mt:", mt, "@err:", err, " @len:", len("testValueIs"))
	log.Println(len("this_is_a_very_long_string__we_just_test_skip_func_is_usefull_does_it_usefull_yes_it_is"))

	ar := strings.Split("hello,world,how,cool,me", ",")
	log.Println("@len:", len(ar))

	s = `
		this
		is
		a
		hello
		world
	`
	log.Println(s)
	log.Println(strings.Replace(s, "\n", " ", -1))
	log.Println(s)

	val := `{"name":"asdfasdf","platform":1,"segmentId":"","step":1,"accurate":0,"msg":null}`
	badSeg := "\"segmentId\":\"\","
	val = strings.Replace(val, badSeg, "", 1)
	log.Println(string(val))

}
Пример #5
0
func main() {
	log.Println("hello")
	go respProcess()
	t := 10000
	st := utee.Tick()
	for i := 0; i < t; i++ {
		//		latch.Acquire()
		//		go
		test()
	}
	cost := utee.Tick() - st
	log.Println("@times:", t, " invoke cost:", cost, " second")
	//	time.Sleep(time.Second*time.Duration(2))
	for {
		if len(resp_chan) == 0 {
			tcost := utee.Tick() - st
			log.Println("@times:", t, " invoke total cost:", tcost, " second")
			os.Exit(1)
		}
	}
}