Esempio n. 1
0
func BenchmarkConnStreamerParseEvents(b *testing.B) {
	filename := testfiles.Locate("binlog_test/vt-0000062347-bin.000001")
	var svm sync2.ServiceManager
	count := 0
	bls := &binlogConnStreamer{dbname: "vt_test_database", sendTransaction: func(tx *proto.BinlogTransaction) error {
		count++
		return nil
	}}

	for i := 0; i < b.N; i++ {
		events := readEvents(b, filename)
		svm.Go(func(svc *sync2.ServiceContext) error {
			_, err := bls.parseEvents(svc, events)
			return err
		})
		if err := svm.Join(); err != ServerEOF {
			b.Errorf("%v", err)
		}
	}

	b.Logf("%d transactions processed", count)
}
Esempio n. 2
0
func BenchmarkFileStreamerParseEvents(b *testing.B) {
	filename := testfiles.Locate("binlog_test/vt-0000062347-bin.000001")
	var svm sync2.ServiceManager
	count := 0
	bls := newTestBinlogFileStreamer("vt_test_database", "", myproto.ReplicationPosition{}, func(tx *proto.BinlogTransaction) error {
		count++
		return nil
	})

	for i := 0; i < b.N; i++ {
		if err := bls.file.Init(filename, 0); err != nil {
			b.Fatalf("%v", err)
		}
		svm.Go(bls.run)
		if err := svm.Join(); err != nil {
			b.Errorf("%v", err)
		}
		bls.file.Close()
	}

	b.Logf("%d transactions processed", count)
}