MCPcopy Create free account
hub / github.com/pingcap/tidb / BenchmarkEncodeValue

Function BenchmarkEncodeValue

pkg/tablecodec/tablecodec_test.go:557–579  ·  view source on GitHub ↗

Bench result: BenchmarkEncodeValue 5000000 368 ns/op

(b *testing.B)

Source from the content-addressed store, hash-verified

555// Bench result:
556// BenchmarkEncodeValue 5000000 368 ns/op
557func BenchmarkEncodeValue(b *testing.B) {
558 sc := stmtctx.NewStmtCtx()
559
560 row := make([]types.Datum, 7)
561 row[0] = types.NewIntDatum(100)
562 row[1] = types.NewBytesDatum([]byte("abc"))
563 row[2] = types.NewDecimalDatum(types.NewDecFromInt(1))
564 row[3] = types.NewMysqlEnumDatum(types.Enum{Name: "a", Value: 0})
565 row[4] = types.NewDatum(types.Set{Name: "a", Value: 0})
566 row[5] = types.NewDatum(types.BinaryLiteral{100})
567 row[6] = types.NewFloat32Datum(1.5)
568 b.ResetTimer()
569 encodedCol := make([]byte, 0, 16)
570 for i := 0; i < b.N; i++ {
571 for _, d := range row {
572 encodedCol = encodedCol[:0]
573 _, err := EncodeValue(sc.TimeZone(), encodedCol, d)
574 if err != nil {
575 b.Fatal(err)
576 }
577 }
578 }
579}
580
581func TestError(t *testing.T) {
582 kvErrs := []*terror.Error{

Callers

nothing calls this directly

Calls 10

NewStmtCtxFunction · 0.92
NewIntDatumFunction · 0.92
NewBytesDatumFunction · 0.92
NewDecimalDatumFunction · 0.92
NewDecFromIntFunction · 0.92
NewMysqlEnumDatumFunction · 0.92
NewDatumFunction · 0.92
NewFloat32DatumFunction · 0.92
TimeZoneMethod · 0.80
EncodeValueFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…