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


Golang B.FailNow方法代码示例

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


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

示例1: BenchmarkJournalQueuePop

func BenchmarkJournalQueuePop(b *testing.B) {
	b.N = 1000000
	var err error
	var p []byte
	var fq Queue
	if fq, err = NewJournalQueue(fpath); err != nil {
		panic(err)
	}
	defer fq.Close()
	defer os.RemoveAll(fpath)
	b.ResetTimer()
	b.StartTimer()
	var total int64 = 0
	for i := 0; i < b.N; i++ {
		if p, err = fq.Pop(); err != nil {
			b.FailNow()
			return
		}
		total += int64(len(p))
		c := int(binary.LittleEndian.Uint32(p))
		l := int(binary.LittleEndian.Uint32(p[4:]))
		if c != i || l != len(p) {
			b.FailNow()
		}
	}
	b.SetBytes(total / int64(b.N))
	b.StopTimer()
}
开发者ID:Joinhack,项目名称:fqueue,代码行数:28,代码来源:journalqueue_bench_test.go

示例2: benchReflect

func benchReflect(b *testing.B, path string) {
	for i := 0; i < b.N; i++ {
		if Reflect(input, path) == nil {
			b.FailNow()
		}
	}
}
开发者ID:gitter-badger,项目名称:botcommentator,代码行数:7,代码来源:reflect_test.go

示例3: Benchmark6

func Benchmark6(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if Sort(6) {
			b.FailNow()
		}
	}
}
开发者ID:eikeon,项目名称:funnelsort,代码行数:7,代码来源:sort_test.go

示例4: BenchmarkHbasePut

func BenchmarkHbasePut(b *testing.B) {
	var (
		err error
		h   = NewHBaseClient()
		m   = &meta.Needle{}
		t   int64
	)
	ch := make(chan int64, 1000000)
	if err = Init("172.16.13.90:9090", 5*time.Second, 200, 200); err != nil {
		b.Errorf("Init failed")
		b.FailNow()
	}
	for j := 0; j < 1000000; j++ {
		k := int64(time.Now().UnixNano())
		ch <- k
	}
	b.ResetTimer()
	b.SetParallelism(8)
	b.RunParallel(func(pb *testing.PB) {
		for pb.Next() {
			t = <-ch
			m.Key = t
			if err = h.Put(m); err != nil {
				continue
			}
		}
	})
}
开发者ID:xiaoma20082008,项目名称:bfs,代码行数:28,代码来源:hbase_b_test.go

示例5: 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

示例6: BenchmarkPipeShareRouter

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

	hf := NewMsgHeaderFactory(pbt.NewMsgProtobufFactory())

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

	name := "scheduler"
	n := ConcurrentNum
	m := GoRoutineRequests
	for i := 0; i < n; i++ {
		c, s := net.Pipe()
		ep_c := r.newRouterEndPoint(name+string(i), c, hf)
		ep_s := r.newRouterEndPoint("client"+string(n), s, hf)
		r.AddEndPoint(ep_c)
		r.AddEndPoint(ep_s)
	}

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

示例7: runVmBench

func runVmBench(test vmBench, b *testing.B) {
	db, _ := ethdb.NewMemDatabase()
	sender := state.NewStateObject(common.Address{}, db)

	if test.precompile && !test.forcejit {
		NewProgram(test.code)
	}
	env := NewEnv()

	EnableJit = !test.nojit
	ForceJit = test.forcejit

	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		context := NewContext(sender, sender, big.NewInt(100), big.NewInt(10000), big.NewInt(0))
		context.Code = test.code
		context.CodeAddr = &common.Address{}
		_, err := New(env).Run(context, test.input)
		if err != nil {
			b.Error(err)
			b.FailNow()
		}
	}
}
开发者ID:este-xx,项目名称:go-expanse,代码行数:25,代码来源:jit_test.go

示例8: 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

示例9: benchmarkStoreRead

func benchmarkStoreRead(b *testing.B, store data.Store) {
	var n = 1000
	benchmarkStoreInsert(b, store, n)
	b.ResetTimer()
	var users = store.Collection("users")
	for k := 0; k < b.N; k++ {
		var i = rand.Intn(n - 1)
		var name = fmt.Sprintf("user%d", i+1)
		var email = fmt.Sprintf("%[email protected]", name)
		var usr User
		var err = users.Find(q.Or{
			q.M{"id": name},
			q.M{"name": name},
			q.M{"email": name},
		}).One(&usr)
		if err != nil {
			b.Errorf("find one failed with %v", err)
			b.FailNow()
		}
		err = users.Find(q.Or{
			q.M{"id": email},
			q.M{"name": email},
			q.M{"email": email},
		}).One(&usr)
		if err != nil {
			b.Errorf("find one failed with %v", err)
			b.FailNow()
		}
	}
}
开发者ID:gocontrib,项目名称:nosql,代码行数:30,代码来源:store_test.go

示例10: BenchmarkLoadModel

func BenchmarkLoadModel(b *testing.B) {
	client := New("127.0.0.1:8087")
	err := client.Connect()
	if err != nil {
		b.FailNow()
	}
	// Create a new "DocumentModel" and save it
	doc := DMInclude{Name: "some name", Sub: SubStruct{Value: "some value"}}
	err = client.New("testmodel.go", "BenchModelKey", &doc)
	if err != nil {
		b.Log(err)
		b.FailNow()
	}
	err = doc.Save()
	if err != nil {
		b.Log(err)
		b.Fail()
	}

	for i := 0; i < b.N; i++ {
		err = client.Load("testmodel.go", "BenchModelKey", &doc, R1)
		if err != nil {
			b.Log(err)
			b.Fail()
		}
	}
}
开发者ID:lucmichalski,项目名称:crawler,代码行数:27,代码来源:benchmark_test.go

示例11: BenchmarkMain

func BenchmarkMain(tst *testing.B) {
	conn, err := grpc.Dial("localhost:4567", grpc.WithBlock())
	if err != nil {
		os.Exit(1)
	}
	defer conn.Close()

	client := pb.NewPingClient(conn)

	tst.ResetTimer()
	for n := 0; n < tst.N; n++ {
		ctx := context.Background()
		t := time.Now()
		req := pb.PingRequest{t.UnixNano()}
		_, err := client.Ping(ctx, &req)
		if err != nil {
			tst.FailNow()
		}

		/*
			t2 := time.Now()

			then := time.Unix(0, resp.TimeBack)

			reqdelay := then.Sub(t)
			log.Println("req ", reqdelay)

			repdelay := t2.Sub(then)
			log.Println("rep ", repdelay)
		*/
	}
}
开发者ID:tcolgate,项目名称:test,代码行数:32,代码来源:main_test.go

示例12: startFakeBookingApp

func startFakeBookingApp(b *testing.B) {
	Init("", "github.com/robfig/revel/samples/booking", "")

	// Disable logging.
	TRACE = log.New(ioutil.Discard, "", 0)
	INFO = TRACE
	WARN = TRACE
	ERROR = TRACE

	MainRouter = NewRouter("")
	routesFile, _ := ioutil.ReadFile(filepath.Join(BasePath, "conf", "routes"))
	MainRouter.parse(string(routesFile), false)
	MainTemplateLoader = NewTemplateLoader([]string{ViewsPath})
	MainTemplateLoader.Refresh()

	RegisterController((*Hotels)(nil),
		[]*MethodType{
			&MethodType{
				Name: "Show",
				Args: []*MethodArg{
					{"id", reflect.TypeOf((*int)(nil))},
				},
				RenderArgNames: map[int][]string{30: []string{"title", "hotel"}},
			},
		})

	RegisterController((*Static)(nil),
		[]*MethodType{
			&MethodType{
				Name: "Serve",
				Args: []*MethodArg{
					&MethodArg{Name: "prefix", Type: reflect.TypeOf((*string)(nil))},
					&MethodArg{Name: "filepath", Type: reflect.TypeOf((*string)(nil))},
				},
				RenderArgNames: map[int][]string{},
			},
		})

	plugins.OnAppStart()

	resp := httptest.NewRecorder()

	// First, test that the expected responses are actually generated
	handle(resp, showRequest)
	if !strings.Contains(resp.Body.String(), "300 Main St.") {
		b.Errorf("Failed to find hotel address in action response:\n%s", resp.Body)
		b.FailNow()
	}
	resp.Body.Reset()

	handle(resp, staticRequest)
	if resp.Body.Len() != 6712 {
		b.Errorf("Expected sessvars.js to have 6712 bytes, got %d:\n%s", resp.Body.Len(), resp.Body)
		b.FailNow()
	}

	resp.Body = nil
	b.ResetTimer()
}
开发者ID:kyleconroy,项目名称:revel,代码行数:59,代码来源:server_test.go

示例13: BenchmarkShorten

func BenchmarkShorten(b *testing.B) {
	for i := 0; i < b.N; i++ {
		shortid := Shorten()
		if len(shortid) != 6 {
			b.FailNow()
		}
	}
}
开发者ID:gokyle,项目名称:opmlfeed,代码行数:8,代码来源:shorten_test.go

示例14: BenchmarkGenerateKeyP256

// Benchmark the generation of P256 keys.
func BenchmarkGenerateKeyP256(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if _, err := GenerateKey(rand.Reader, elliptic.P256(), nil); err != nil {
			fmt.Println(err.Error())
			b.FailNow()
		}
	}
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:9,代码来源:ecies_test.go

示例15: BenchmarkCheckRequestSignature

func BenchmarkCheckRequestSignature(b *testing.B) {
	for i := 0; i < b.N; i++ {
		if !CheckRequestSignature(req1, signerPub) {
			fmt.Print("crypto: signature verification failed")
			b.FailNow()
		}
	}
}
开发者ID:postfix,项目名称:arx,代码行数:8,代码来源:crypto_test.go


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