本文整理汇总了Golang中testing.B.Skip方法的典型用法代码示例。如果您正苦于以下问题:Golang B.Skip方法的具体用法?Golang B.Skip怎么用?Golang B.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testing.B
的用法示例。
在下文中一共展示了B.Skip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: BenchmarkCacheComplete
func BenchmarkCacheComplete(b *testing.B) {
b.StopTimer()
paths := DefaultPaths()
if len(paths) == 0 {
b.Skip("No default paths available")
}
tests := []string{"mscorlib.dll", "System.dll"}
c := Cache{paths: paths}
for _, test := range tests {
if _, err := c.Load(test); err != nil {
b.Error(err)
}
}
tests2 := []content.Type{
content.Type{Name: content.FullyQualifiedName{Absolute: "net://type/System.String"}},
}
b.StartTimer()
for i := 0; i < b.N; i++ {
for _, test := range tests2 {
if _, err := c.Complete(&test); err != nil {
b.Error(err)
}
}
}
}
示例2: Benchmark_Proto_Binary
func Benchmark_Proto_Binary(b *testing.B) {
b.Skip()
srv := &binaryTestServer{&baseTestServer{}}
port, err := srv.listen()
assert.NoError(b, err)
srv.start()
defer srv.Stop()
client, err := rpc.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", port))
assert.NoError(b, err)
defer client.Close()
b.Log(port)
b.ResetTimer()
for i := 0; i < b.N; i++ {
b.StartTimer()
var res TestMessage
req := TestMessage{
"12345678910",
[]byte("mama myla ramu"),
}
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))
}
}
示例3: 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))
}
}
示例4: bench
func bench(b *testing.B, size int, algo func(Interface), name string) {
if stringspkg.HasSuffix(testenv.Builder(), "-race") && size > 1e4 {
b.Skip("skipping slow benchmark on race builder")
}
b.StopTimer()
data := make(intPairs, size)
x := ^uint32(0)
for i := 0; i < b.N; i++ {
for n := size - 3; n <= size+3; n++ {
for i := 0; i < len(data); i++ {
x += x
x ^= 1
if int32(x) < 0 {
x ^= 0x88888eef
}
data[i].a = int(x % uint32(n/5))
}
data.initB()
b.StartTimer()
algo(data)
b.StopTimer()
if !IsSorted(data) {
b.Errorf("%s did not sort %d ints", name, n)
}
if name == "Stable" && !data.inOrder() {
b.Errorf("%s unstable on %d ints", name, n)
}
}
}
}
示例5: BenchmarkRequestsTLSoTCP
func BenchmarkRequestsTLSoTCP(b *testing.B) {
// Benchmarks the rate at which we can serve requests over a single,
// TLS encrypted TCP channel over the loopback interface.
// Load a certificate, skipping this benchmark if it doesn't exist
cert, err := tls.LoadX509KeyPair("../../test/h1/cert.pem", "../../test/h1/key.pem")
if err != nil {
b.Skip(err)
return
}
// Get a connected TCP pair
conn0, conn1, err := getTCPConnectionPair()
if err != nil {
b.Fatal(err)
}
/// TLSify them
conn0, conn1 = negotiateTLS(cert, conn0, conn1)
defer conn0.Close()
defer conn1.Close()
// Bench it
benchmarkRequestsConnPair(b, conn0, conn1)
}
示例6: BenchmarkAppendLog
func BenchmarkAppendLog(b *testing.B) {
bucketName := "bucketName"
ownerName := "ownerName"
artifactName := "artifactName"
if testing.Short() {
b.Skip("Skipping end-to-end test in short mode.")
}
client := setup(b)
bucket, _ := client.NewBucket(bucketName, ownerName, 31)
require.NotNil(b, bucket)
artifact, _ := bucket.NewChunkedArtifact(artifactName)
require.NotNil(b, artifact)
// Typical logchunk of size ~4KB
str := gen4KString()
// Each 4K chunks sent takes ~1.3ms on a 4-core laptop (with synchronous_commit=off,fsync=off in
// Postgres)
b.ResetTimer()
for i := 0; i < b.N; i++ {
artifact.AppendLog(str)
}
// Make sure all logchunks are sent to API/DB.
artifact.Flush()
}
示例7: BenchmarkStoreLeveldbDocs720
func BenchmarkStoreLeveldbDocs720(b *testing.B) {
if testing.Short() {
b.Skip("Skipping large store test in short mode")
}
runStoreBench(b, "leveldb", 720)
}
示例8: BenchmarkRedisClusterPing
func BenchmarkRedisClusterPing(b *testing.B) {
if testing.Short() {
b.Skip("skipping in short mode")
}
cluster := &clusterScenario{
ports: []string{"8220", "8221", "8222", "8223", "8224", "8225"},
nodeIds: make([]string, 6),
processes: make(map[string]*redisProcess, 6),
clients: make(map[string]*redis.Client, 6),
}
if err := startCluster(cluster); err != nil {
b.Fatal(err)
}
defer stopCluster(cluster)
client := cluster.clusterClient(nil)
defer client.Close()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if err := client.Ping().Err(); err != nil {
b.Fatal(err)
}
}
})
}
示例9: 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))
}
}
示例10: BenchmarkRoundtripFileBoom
func BenchmarkRoundtripFileBoom(b *testing.B) {
if *file == "" {
b.Skip("no file specified")
}
for i := 0; i < b.N; i++ {
br, err := boom.OpenBAM(*file)
if err != nil {
b.Fatalf("Open failed: %v", err)
}
f, err := os.OpenFile("/dev/null", os.O_APPEND|os.O_RDWR, 0666)
if err != nil {
b.Fatalf("Open failed: %v", err)
}
bw, err := boom.OpenBAMFile(f, "bw", br.Header())
if err != nil {
b.Fatalf("NewWriter failed: %v", err)
}
for {
r, _, err := br.Read()
if err != nil {
break
}
_, err = bw.Write(r)
if err != nil {
b.Fatalf("Write failed: %v", err)
}
}
br.Close()
f.Close()
}
}
示例11: BenchmarkAtomicIncrement
func BenchmarkAtomicIncrement(store data.Store, b *testing.B) {
if err := store.SetLifetime(time.Second*30, data.ScopeAll); err != nil {
b.Skip("Set lifetime to all items is not supported")
}
b.ResetTimer()
b.SetParallelism(50)
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if _, err := store.Increment("key001"); err != nil {
b.Errorf("Could not increment value: %v", err)
}
}
})
b.StopTimer()
var result int
if err := store.Get("key001", &result); err != nil {
b.Errorf("Could not get stored value: %v", err)
}
if result != b.N {
b.Errorf("Unexpected value: got %d instead of %d", result, b.N)
}
}
示例12: Benchmark_words_load
func Benchmark_words_load(t *testing.B) {
// wordlist was downloaded from http://www-personal.umich.edu/~jlawler/wordlist
f, err := os.Open("d:\\wordlist.txt")
if err != nil {
t.Skip()
return
}
defer f.Close()
s := bufio.NewScanner(f)
words := make([]string, 0, 80000)
for s.Scan() {
txt := s.Text()
words = append(words, txt)
}
sort.Stable(byStringLengthDesc(words))
tree := NewPrefixedTree("")
for i := range words {
tree.Put(words[i], i)
}
of, err := os.Create("d:\\wordlist.json")
panicif(err)
defer of.Close()
of.WriteString(tree.String())
t.Log("Nodes: ", tree.NodeCount())
t.Log("Max fanout: ", tree.root.MaxFanout())
histogram := make(map[int]int)
tree.root.visit(func(n *Node) bool {
count := len(n.Nodes)
histogram[count] += 1
return true
})
kvs := make([]kv, len(histogram))
i := 0
for k, v := range histogram {
kvs[i] = kv{k, v}
i++
}
sort.Stable(byFanout(kvs))
for i := range kvs {
t.Logf("%+v", kvs[i])
}
t.Logf("=====")
sort.Stable(byCount(kvs))
for i := range kvs {
t.Logf("%+v", kvs[i])
}
tree.root.Walk("abating", func(path string, h int) bool {
t.Logf("%d(%s): %s ", h, path, words[h])
return true
})
}
示例13: BenchmarkArchiveDirectory
func BenchmarkArchiveDirectory(b *testing.B) {
if BenchArchiveDirectory == "" {
b.Skip("benchdir not set, skipping BenchmarkArchiveDirectory")
}
for i := 0; i < b.N; i++ {
archiveDirectory(b)
}
}
示例14: BenchmarkEnumerateBlobMetaSQLite
// Testing EnumerateBlobMeta because that's one of the few non-corpus index reading ops we still actually use.
func BenchmarkEnumerateBlobMetaSQLite(b *testing.B) {
if *flagBenchDir == "" {
b.Skip("Enumerating benchmark needs -benchDir")
}
dbfile := filepath.Join(*flagBenchDir, "sqlite.db")
enumerateMeta(b, dbfile, func(dbfile string) (sorted.KeyValue, error) {
return sqlite.NewStorage(dbfile)
})
}
示例15: BenchmarkInterruptSQLite
func BenchmarkInterruptSQLite(b *testing.B) {
if *flagBenchDir == "" {
b.Skip("Interrupt benchmark needs -benchDir")
}
dbfile := filepath.Join(*flagBenchDir, "sqlite.db")
benchmarkKillReindex(b, 15, dbfile, func(dbfile string) (sorted.KeyValue, error) {
return sqlite.NewStorage(dbfile)
})
}