当前位置: 首页>>代码示例>>Golang>>正文


Golang B.Log方法代码示例

本文整理汇总了Golang中testing.B.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang B.Log方法的具体用法?Golang B.Log怎么用?Golang B.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在testing.B的用法示例。


在下文中一共展示了B.Log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: benchAddRemove

func benchAddRemove(amount int, b *testing.B) {
	g := New(16)
	if len(addRemoveList) > amount {
		addRemoveList = addRemoveList[:amount]
	}
	for n := 0; n < amount; n++ {
		if len(addRemoveList) == amount {
			break
		}
		addRemoveList = append(addRemoveList, random())
	}
	if len(addRemoveList) != amount {
		b.Log("len() reports", len(addRemoveList), "want", amount)
		b.Fail()
		return
	}
	b.ResetTimer()
	for n := 0; n < b.N; n++ {
		for _, s := range addRemoveList {
			g.Add(s)
			if !g.Remove(s) {
				b.Log("failed to remove")
				b.Fail()
			}
		}
	}
}
开发者ID:pombredanne,项目名称:rand,代码行数:27,代码来源:gridex_test.go

示例2: BenchmarkHasFactorBigIntRnd_128b

func BenchmarkHasFactorBigIntRnd_128b(b *testing.B) {
	const N = 1 << 16
	b.StopTimer()
	type t struct {
		d *big.Int
		e uint32
	}
	a := make([]t, N)
	r, err := mathutil.NewFCBig(_1, New(128), true)
	if err != nil {
		b.Fatal(err)
	}
	r2 := r32()
	for i := range a {
		dd := r.Next()
		a[i] = t{
			dd.SetBit(dd, 0, 1),
			uint32(r2.Next()),
		}
	}
	once358.Do(func() { b.Log("Random 128 bit factor, random 32 bit exponent\n") })
	runtime.GC()
	b.StartTimer()
	for i := 0; i < b.N; i++ {
		v := a[i&(N-1)]
		HasFactorBigInt(v.d, v.e)
	}
}
开发者ID:klizhentas,项目名称:acbuild,代码行数:28,代码来源:all_test.go

示例3: BenchmarkInsert

func BenchmarkInsert(t *testing.B) {

	link := NewCycleLink(3, 10000)
	for i := 0; i < t.N; i++ {
		msg := NewMessage(1, 3, MESSAGE_TYPE_SIMPLE)
		link.Insert(uint32(i), msg)
	}

	ch := make(chan *Message)

	go func() {
		link.Remove(0, 0, ch, func(msg *Message) bool {
			return false
		})
	}()

	for {
		tmp := <-ch
		// t.Logf("GET REMOVE -------%t\n", tmp)
		if nil == tmp {
			close(ch)
			break
		}
	}

	t.Log("HEADER---------\n")

	// PrintLink(t, link)
}
开发者ID:peter158,项目名称:go-apns,代码行数:29,代码来源:cycle_link_test.go

示例4: BenchmarkPMap

func BenchmarkPMap(b *testing.B) {
	source := sourceData()
	for i := 0; i < b.N; i++ {
		fibs := PMaps(source, fib).([]int)
		b.Log(len(fibs))
	}
}
开发者ID:benashford,项目名称:go-func,代码行数:7,代码来源:func_test.go

示例5: BenchmarkEcho

func BenchmarkEcho(b *testing.B) {
	b.StopTimer() // Initialize
	sockPath := Fmt("unix:///tmp/echo_%v.sock", RandStr(6))
	// Start server
	s, err := server.NewServer(sockPath, dummy.NewDummyApplication())
	if err != nil {
		Exit(err.Error())
	}
	defer s.Stop()
	// Start client
	proxy, err := NewRemoteAppConn(sockPath)
	if err != nil {
		Exit(err.Error())
	} else {
		b.Log("Connected")
	}
	echoString := strings.Repeat(" ", 200)
	b.StartTimer() // Start benchmarking tests

	for i := 0; i < b.N; i++ {
		proxy.EchoAsync(echoString)
	}
	proxy.FlushSync()

	b.StopTimer()
	// info := proxy.InfoSync()
	//b.Log("N: ", b.N, info)
}
开发者ID:eris-ltd,项目名称:tendermint,代码行数:28,代码来源:remote_app_conn_test.go

示例6: benchmarkInsertAll

func benchmarkInsertAll(b *testing.B, size uint32, creator func(int) Inserter) {

	if strData == nil {
		loadStringData("/home/dgryski/strings.out")
	}

	b.ResetTimer()

	var total uint32
	var hits int
	for i := 0; i < b.N; i++ {

		ht := creator(int(size))

		for j, s := range strData {
			v, ok := ht.Insert(s, uint32(j))
			total += v
			if ok {
				hits += 1
			}
		}
	}

	b.StopTimer()

	b.Log("N=", b.N, "size=", size, "total=", total, "hits=", hits)
}
开发者ID:KanwarGill,项目名称:trifles,代码行数:27,代码来源:strtable_test.go

示例7: Benchmark_Proto_HTTP_Large

func Benchmark_Proto_HTTP_Large(b *testing.B) {
	b.Skip()
	srv := &httpTestServer{&baseTestServer{}}
	port, err := srv.listen()
	assert.NoError(b, err)
	srv.start()
	defer srv.Stop()

	client, err := rpc.DialHTTPPath("tcp",
		fmt.Sprintf("127.0.0.1:%d", port), "/v1/rpc")
	assert.NoError(b, err)
	defer client.Close()

	b.Log(port, b.N)

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		b.StartTimer()
		var res TestMessage
		req := TestMessage{
			fmt.Sprintf("%d", i),
			[]byte(strings.Repeat("0", 1024*1024)),
		}
		err = client.Call("ServiceFixture.Ping", &req, &res)
		b.StopTimer()
		assert.NoError(b, err)
		assert.Equal(b, req, res)
		b.SetBytes(int64(len(req.Data) * 2))
	}
}
开发者ID:pombredanne,项目名称:bar,代码行数:30,代码来源:http_test.go

示例8: Benchmark_Proto_GRPC_Large

func Benchmark_Proto_GRPC_Large(b *testing.B) {
	b.Skip()
	logx.SetLevel(logx.DEBUG)
	srv1 := new(GRPCServer)
	srv1.Start()
	defer srv1.srv.Stop()

	conn, err := grpc.Dial(fmt.Sprintf("localhost:%d", srv1.Port), grpc.WithInsecure())
	assert.NoError(b, err)
	defer conn.Close()

	c := pb3.NewBarClient(conn)

	b.Log(srv1.Port, b.N)

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		b.StartTimer()
		req := pb3.TestRep{
			fmt.Sprintf("%d", i),
			[]byte(strings.Repeat("m", 1024*1024)),
		}
		res, err := c.Test(context.Background(), &req)
		b.StopTimer()
		assert.NoError(b, err)
		assert.EqualValues(b, req, *res)
		b.SetBytes(int64(len(req.Body) * 2))
	}
}
开发者ID:pombredanne,项目名称:bar,代码行数:29,代码来源:bar_proto_test.go

示例9: BenchmarkHashGet

func BenchmarkHashGet(b *testing.B) {
	mPath := "/test"
	cli := NewZKClient(testServers, time.Second*5, nil)
	defer cli.Close()
	cli.CreatePersistNode(mPath)
	defer cli.DeleteNode(mPath)

	cli.CreateEphemeralNode(mPath + "/127.0.0.1:6379")
	cli.CreateEphemeralNode(mPath + "/127.0.0.1:6380")

	fmt.Println("===============create addr dir===============")
	time.Sleep(2 * time.Second)

	zkm := NewZKMonitor(testServers, time.Second*5, &testService{}, nil, mPath)
	zkm.Run()
	defer zkm.Close()
	time.Sleep(2 * time.Second)

	hGetter := zkm.HashGetter(nil)
	key := []byte{1, 2, 3, 4, 5, 6, 7, 8}

	nilCnt := int32(0)
	b.ResetTimer()
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			key[0] = byte(rand.Int())
			conn := hGetter.GetConn(key)
			if conn == nil {
				atomic.AddInt32(&nilCnt, 1)
			}
		}
	})
	b.Log("nil connection count:", nilCnt)
}
开发者ID:RivenZoo,项目名称:goutil,代码行数:34,代码来源:monitor_test.go

示例10: BenchmarkTCPShareRouter

func BenchmarkTCPShareRouter(b *testing.B) {
	r, err := NewRouter(nil, ServiceProcessPayload)
	if err != nil {
		b.FailNow()
	}

	hf := NewMsgHeaderFactory(pbt.NewMsgProtobufFactory())

	r.Run()
	<-time.Tick(1 * time.Millisecond)

	network := "tcp"
	address := "localhost:10001"
	if err := r.ListenAndServe("client", network, address, hf, ServiceProcessConn); err != nil {
		b.Log(err)
		b.FailNow()
	}

	name := "scheduler"
	n := ConcurrentNum
	m := GoRoutineRequests
	for i := 0; i < n; i++ {
		if err := r.Dial(name+string(i), network, address, hf); err != nil {
			b.Log(err)
			b.FailNow()
		}
	}

	<-time.Tick(1 * time.Millisecond)
	testShareRouter(b, r, n, m)
}
开发者ID:arthurkiller,项目名称:rpc,代码行数:31,代码来源:router_test.go

示例11: testSeperateRouter

func testSeperateRouter(b *testing.B, server_r *Router, client_r *Router, n int, m int) {
	name := "scheduler"
	b.ResetTimer()
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			var wg sync.WaitGroup
			for i := 0; i < m; i++ {
				req := pbt.NewResourceReq()
				req.Id = proto.Uint64(0)
				i := rand.Intn(n)
				if m == 1 {
					if _, err := client_r.CallWait(name+string(i), "rpc", req, 5); err != nil {
						b.Log(err)
						b.FailNow()
					}
				} else {
					wg.Add(1)
					client_r.Call(name+string(i), "rpc", req, ClientProcessReponseWaitGroup, &wg, 0)
				}
			}
			if m > 1 {
				wg.Wait()
			}
		}
	})

	client_r.Stop()
	server_r.Stop()
}
开发者ID:arthurkiller,项目名称:rpc,代码行数:29,代码来源:router_test.go

示例12: BenchmarkYorikko16b

func BenchmarkYorikko16b(b *testing.B) {
	b.Log(Yorikko(test16b))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		Yorikko(test16b)
	}
}
开发者ID:meidoworks,项目名称:nekoq-common,代码行数:7,代码来源:hash_test.go

示例13: Benchmark10k10k

func Benchmark10k10k(b *testing.B) {
	f, err := os.Open("ips10k.txt")
	if err != nil {
		b.Log(err)
		b.FailNow()
	}
	loadSrc(f)
	b.StartTimer()
	fs, err := os.Open("query10k.txt")
	if err != nil {
		b.Log(err)
		b.FailNow()
	}
	b.ReportAllocs()
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		loadStats(fs)

		b.StopTimer()
		for _, v := range allRngs {
			v.count = 0
		}
		unkC = 0
		fs.Seek(0, 0)
		b.StartTimer()
	}
}
开发者ID:Kunde21,项目名称:DailyProgrammer,代码行数:27,代码来源:c245H_test.go

示例14: BenchmarkPodConversion

func BenchmarkPodConversion(b *testing.B) {
	apiObjectFuzzer := apitesting.FuzzerFor(nil, api.SchemeGroupVersion, rand.NewSource(benchmarkSeed))
	items := make([]api.Pod, 4)
	for i := range items {
		apiObjectFuzzer.Fuzz(&items[i])
	}

	// add a fixed item
	data, err := ioutil.ReadFile("pod_example.json")
	if err != nil {
		b.Fatalf("Unexpected error while reading file: %v", err)
	}
	var pod api.Pod
	if err := runtime.DecodeInto(testapi.Default.Codec(), data, &pod); err != nil {
		b.Fatalf("Unexpected error decoding pod: %v", err)
	}
	items = append(items, pod)
	width := len(items)

	scheme := api.Scheme
	var result *api.Pod
	for i := 0; i < b.N; i++ {
		pod := &items[i%width]
		versionedObj, err := scheme.UnsafeConvertToVersion(pod, *testapi.Default.GroupVersion())
		if err != nil {
			b.Fatalf("Conversion error: %v", err)
		}
		obj, err := scheme.UnsafeConvertToVersion(versionedObj, testapi.Default.InternalGroupVersion())
		if err != nil {
			b.Fatalf("Conversion error: %v", err)
		}
		result = obj.(*api.Pod)
	}
	b.Log(result)
}
开发者ID:odacremolbap,项目名称:kubernetes,代码行数:35,代码来源:conversion_test.go

示例15: BenchmarkStoreObject

func BenchmarkStoreObject(b *testing.B) {
	client := New("127.0.0.1:8087")
	err := client.Connect()
	if err != nil {
		b.FailNow()
	}

	for i := 0; i < b.N; i++ {
		bucket, err := client.Bucket("client_test.go")
		if err != nil {
			b.FailNow()
		}
		obj := bucket.New("abc", PW1, DW1)
		if obj == nil {
			b.FailNow()
		}
		obj.ContentType = "text/plain"
		obj.Data = []byte("some more data")
		err = obj.Store()
		if err != nil {
			b.Log(err)
			b.Fail()
		}
	}
}
开发者ID:lucmichalski,项目名称:crawler,代码行数:25,代码来源:benchmark_test.go


注:本文中的testing.B.Log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。