Ejemplo n.º 1
0
func benchlog(chioce int) {
	fmt.Println("chioce:", chioce)

	woolog.SetLogName("/tmp/woo.log")
	woolog.SetLevel(woolog.DEBUG)

	length := 100
	context := "1234567890-=!@#$%^&*(qwertyuiop[]';lkjhgfdsazxcvbnm,./?><:}{)_+"
	for len(context) < length {
		context += context
	}
	context = string([]byte(context)[:length])

	c := 1200000
	fmt.Println("cpu:", runtime.NumCPU(), "len:", len(context), "count:", c, "per:", c/runtime.NumCPU())

	forever := make(chan int64, runtime.NumCPU())
	head := proto.Head{}
	fmt.Println(head)

	for i := 0; i < runtime.NumCPU(); i++ {
		go func() {
			s := time.Now()
			for i := 0; i < c/runtime.NumCPU(); i++ {
				woolog.Info(fmt.Sprintf("sxx:%d uid:%d head%d %d %d %d %d",
					1000002,
					10000000,
					head.Command,
					head.SID,
					head.Len,
					head.RID,
					head.Version))
			}
			forever <- time.Now().Sub(s).Nanoseconds() / 1000
		}()
	}

	for i := 0; i < runtime.NumCPU(); i++ {
		fmt.Println("benchlog", <-forever)
	}
	time.Sleep(2 * time.Second)

}
Ejemplo n.º 2
0
func test1() {
	woolog.SetLevel(woolog.INFO)
	woolog.SetLogName("/tmp/woo.log")
	woolog.Info("hello")
	time.Sleep(2 * time.Second)
}