Example #1
2
func BenchmarkVec32AddSSE2(bench *testing.B) {
	if !CPU.SSE2 {
		bench.SkipNow()
		return
	}
	a := Vec32{1, 2, 3, 4}
	b := Vec32{2, 3, 4, 5}
	for n := 0; n < bench.N; n++ {
		sse2Vec32Add(a, b)
	}
}
Example #2
2
func BenchmarkVec32AddAVX(bench *testing.B) {
	if !CPU.AVX {
		bench.SkipNow()
		return
	}
	a := Vec32{1, 2, 3, 4}
	b := Vec32{2, 3, 4, 5}
	for n := 0; n < bench.N; n++ {
		avxVec32Add(a, b)
	}
}
Example #3
1
// BenchmarkDAWG ...
func BenchmarkDAWG(b *testing.B) {
	b.N = 0
	initBenchCtx()
	dict := loadDict(benchCtx.Words100k)
	DAWG := loadDAWG()
	bytesDAWG := loadBytesDAWG()
	recordDAWG := loadRecordDAWG()
	intDAWG := loadIntDAWG()

	tests := []testOp{
		{"get() (hits)", "M ops/sec", 10, 3, 5, getHitBench},
		{"get() (misses)", "M ops/sec", 100, 5, 5, getMissesBench},
		{"__contains__ (hits)", "M ops/sec", 10, 3, 5, containsHitBench},
		{"__contains__ (misses)", "M ops/sec", 10, 3, 5, containsMissesBench},
		{"items()", " ops/sec", 1, 1, 5, itemsBench},
		{"keys()", " ops/sec", 1, 1, 5, keysBench},
	}

	fmt.Printf("\n====== Benchmarks (100k unique unicode words) =======\n\n")

	for _, test := range tests {
		bench(dict, "      dict", test)
		bench(DAWG, "      DAWG", test)
		bench(bytesDAWG, " BytesDAWG", test)
		bench(recordDAWG, "RecordDAWG", test)
		bench(intDAWG, "   IntDAWG", test)
		fmt.Println()
	}
	b.SkipNow()
}
Example #4
1
func Benchmark_appendFetchFinish(b *testing.B) {
	store := testStore(true)
	defer func() {
		store.Destroy()
	}()
	b.SkipNow()
}
Example #5
1
func BenchmarkFluentdHandler(b *testing.B) {
	if fluentdAddr == "" {
		b.SkipNow()
	}

	benchmarkHandler(b, NewFluentdHandler(fluentdAddr, "rglog.test"))
}
Example #6
1
func BenchmarkSyslogHandler(b *testing.B) {
	if !testSyslogHandlerFlag {
		b.SkipNow()
	}

	benchmarkHandler(b, NewSyslogHandler("go-lib"))
}
func BenchmarkHash64(b *testing.B) {
	if runtime.GOARCH != "amd64" {
		b.SkipNow()
	}
	b.SetBytes(int64(len(buf)))
	for i := 0; i < b.N; i++ {
		Hash64(0, buf)
	}
}
Example #8
1
// Comparison to see how much overhead the rand
// operations in BenchmarkpowMod are consuming
func BenchmarkRand(b *testing.B) {
	b.SkipNow()
	bt := []byte{0, 0, 0, 0}
	var x uint16
	for n := 0; n < b.N; n++ {
		rand.Read(bt)
		x = (uint16(bt[0]) << 8) + uint16(bt[1])
		x = (uint16(bt[2]) << 8) + uint16(bt[3])
	}
	if false {
		b.Log(x) //or it complains about unused x
	}
}
Example #9
1
func Benchmark_appendFetchSetup(b *testing.B) {
	store := testStore(true)
	defer func() {
		store.Close()
	}()

	data := "abcdefghijklmnopqrstuvwxyz " + "abcdefghijklmnopqrstuvwxyz "
	data += data
	data += data
	for i := 0; i < maxEntries; i++ {
		fposs = append(fposs, store.appendKey([]byte(data)))
	}
	b.SkipNow()
}
Example #10
0
func BenchmarkGQTPClient(b *testing.B) {
	b.SkipNow()
	client := NewClient("gqtp", "localhost", 10043)
	params := map[string]string{
		"table": "Users",
		"query": "name:@Jim",
	}
	for n := 0; n < b.N; n++ {
		result, _ := client.Call("select", params)
		if len(result.RawData) == 0 {
			b.Errorf("response body not found")
		}
	}
}
Example #11
0
func BenchmarkStreamRead(t *testing.B) {
	buf := make([]byte, 1024*1024)
	t.SetBytes(int64(len(buf)))

	fn := defaultPlainDir + "BenchmarkWrite"
	fi, err := os.Stat(fn)
	if err != nil {
		t.Fatal(err)
	}
	mb := int(fi.Size() / 1024 / 1024)

	if t.N > mb {
		// Grow file so we can satisfy the test
		//fmt.Printf("Growing file to %d MB... ", t.N)
		f2, err := os.OpenFile(fn, os.O_WRONLY|os.O_APPEND, 0666)
		if err != nil {
			fmt.Println(err)
			t.FailNow()
		}
		for h := 0; h < t.N-mb; h++ {
			_, err = f2.Write(buf)
			if err != nil {
				fmt.Println(err)
				t.FailNow()
			}
		}
		f2.Close()
		//fmt.Printf("done\n")
	}

	file, err := os.Open(fn)
	if err != nil {
		t.FailNow()
	}
	t.ResetTimer()
	var i int
	for i = 0; i < t.N; i++ {
		_, err := file.Read(buf)
		if err == io.EOF {
			fmt.Printf("Test file too small\n")
			t.SkipNow()
		} else if err != nil {
			fmt.Println(err)
			t.FailNow()
		}
	}
	file.Close()
}
Example #12
0
func benchmarkMemory(b *testing.B, q intqueue) {
	b.SkipNow()
	b.ReportAllocs()

	b.N = 30000000

	for i := 0; i < b.N; i++ {
		q.add(i)
	}

	for i := 0; i < b.N; i++ {
		q.remove()
	}

	b.Logf(memory())
}
Example #13
0
// Check how fast a sorted list of 8192 items would be
func BenchmarkIndexAsListBinarySearch8192(b *testing.B) {
	b.SkipNow()

	s := make([]int, 8192)
	for x := 0; x < 8192; x++ {
		s[x] = rand.Int()
	}

	sort.Ints(s)

	b.StartTimer()
	for x := 0; x < b.N; x++ {
		sort.SearchInts(s, rand.Int())
	}
	b.StopTimer()
}
Example #14
0
func BenchmarkProbingMapMem(b *testing.B) {
	fillData()

	ms := make([]*__Map, *numReplicas)
	measureMem("probing", func() {
		for i := range ms {
			m := testMap()
			if i == 0 {
				b.Logf("probing: %d keys; %d buckets; load factor %.2f", m.Size(), len(m.buckets), float64(m.Size())/float64(len(m.buckets)))
			}
			ms[i] = m
		}
	}, b)

	b.SkipNow()
}
Example #15
0
func BenchmarkS3Put(b *testing.B) {
	if testutil.SkipS3 {
		b.SkipNow()
	}

	benchBucket = testutil.Upgrade(testutil.TempS3Bucket("BenchmarkPutS3"))

	for i := 0; i < b.N; i++ {
		n, err := Put(benchBucket, testutil.TempDir, []string{"data"})
		if err != nil {
			b.Fatalf("Put failed: %s", err)
		}
		b.SetBytes(n)
	}
	benchPutOk = true
}
Example #16
0
func BenchmarkGoMapMem(b *testing.B) {
	fillData()

	ms := make([]map[__Key]__Value, *numReplicas)
	measureMem("go-map", func() {
		for i := range ms {
			m := make(map[__Key]__Value)
			for _, k := range keys {
				m[k] = __Value(k + 1)
			}
			ms[i] = m
		}
	}, b)

	b.SkipNow()
}
Example #17
0
func BenchmarkOpenClose(b *testing.B) {
	b.SkipNow()
	config := &mysql551.Config{
		Host:     "tcp(localhost:3306)",
		User:     "******",
		Password: "",
		Database: "mysql551_test",
	}

	m := mysql551.New(config)

	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		m.Open()
		m.Close()
	}
}
Example #18
0
func BenchmarkS3Get(b *testing.B) {
	if testutil.SkipS3 {
		b.SkipNow()
	}
	if !benchPutOk {
		b.Skipf("did not run BenchmarkS3Put")
	}

	destDir := filepath.Join(testutil.TempDir, "dest-s3-benchmark")

	for i := 0; i < b.N; i++ {
		n, err := Get(benchBucket, destDir)
		if err != nil {
			b.Fatalf("Get failed: %s", err)
		}
		b.SetBytes(n)
	}
}
Example #19
0
func benchmarkEncodeSize(b *testing.B, points int) {
	do := func(data []point, desc string) {
		s := New(data[0].t)
		for _, tt := range data[0:points] {
			s.Push(tt.t, tt.v)
		}
		size := len(s.Bytes())
		BPerPoint := float64(size) / float64(points)
		b.Logf("encode %d %s points: %6d Bytes. %.2f B/point\n", points, desc, size, BPerPoint)
	}
	do(DataZeroFloats, "all zeroes      float")
	do(DataSameFloats, "all the same    float")
	do(DataSmallRangePosInts, "small range pos   int")
	do(DataSmallRangePosFloats, "small range pos float")
	do(DataLargeRangePosFloats, "large range pos float")
	do(DataRandomPosFloats, "random positive float")
	do(DataRandomFloats, "random pos/neg  float")
	b.SkipNow()
}
Example #20
-1
func benchmarkQuery(b *testing.B, q *client.Query) {
	if *index == "" {
		b.SkipNow()
	}

	c, e := NewClient("-load_index", *index)
	if e != nil {
		b.Fatal(e.Error())
	}

	for i := 0; i < b.N+1; i++ {
		if i == 1 {
			// Don't count the first run+setup, to make
			// sure everything is primed.
			b.ResetTimer()
		}
		if e := c.Err(); e != nil {
			b.Fatalf("err: %s", e.Error())
		}
		s, e := c.Query(q)
		if e != nil {
			b.Fatalf("query: %s", e.Error())
		}
		for _ = range s.Results() {
		}
		if _, e := s.Close(); e != nil {
			b.Fatalf("close: %s", e.Error())
		}
	}
}