MCPcopy Index your code
hub / github.com/lib/pq / BenchmarkEncode

Function BenchmarkEncode

encode_test.go:454–488  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

452}
453
454func BenchmarkEncode(b *testing.B) {
455 b.Run("int64", func(b *testing.B) {
456 for i := 0; i < b.N; i++ {
457 encode(int64(1234), oid.T_int8)
458 }
459 })
460 b.Run("float64", func(b *testing.B) {
461 for i := 0; i < b.N; i++ {
462 encode(3.14159, oid.T_float8)
463 }
464 })
465 b.Run("bool", func(b *testing.B) {
466 for i := 0; i < b.N; i++ {
467 encode(true, oid.T_bool)
468 }
469 })
470 b.Run("timestamptz", func(b *testing.B) {
471 x := time.Date(2001, time.January, 1, 0, 0, 0, 0, time.Local)
472 for i := 0; i < b.N; i++ {
473 encode(x, oid.T_timestamptz)
474 }
475 })
476 b.Run("bytea_hex", func(b *testing.B) {
477 x := []byte("abcdefghijklmnopqrstuvwxyz")
478 for i := 0; i < b.N; i++ {
479 encode(x, oid.T_bytea)
480 }
481 })
482 b.Run("bytea_escape", func(b *testing.B) {
483 x := []byte("abcdefghijklmnopqrstuvwxyz")
484 for i := 0; i < b.N; i++ {
485 encode(x, oid.T_bytea)
486 }
487 })
488}
489
490func BenchmarkAppendEscapedText(b *testing.B) {
491 b.Run("100 lines", func(b *testing.B) {

Callers

nothing calls this directly

Calls 1

encodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…