MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / BenchmarkUserDataRedact

Function BenchmarkUserDataRedact

base/redactor_userdata_test.go:64–92  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

62}
63
64func BenchmarkUserDataRedact(b *testing.B) {
65 defer func() { RedactUserData = defaultRedactUserData }()
66
67 username := UserData("alice")
68 usernameSlice := UD([]string{"adam", "ben", "jacques"})
69
70 // We'd expect a minor performance hit when redaction is enabled.
71 b.Run("Enabled", func(bn *testing.B) {
72 RedactUserData = true
73 for i := 0; i < bn.N; i++ {
74 username.Redact()
75 }
76 })
77
78 b.Run("EnabledSlice", func(bn *testing.B) {
79 RedactUserData = true
80 for i := 0; i < bn.N; i++ {
81 usernameSlice.Redact()
82 }
83 })
84
85 // When redaction is disabled, we should see no performance hit.
86 b.Run("Disabled", func(bn *testing.B) {
87 RedactUserData = false
88 for i := 0; i < bn.N; i++ {
89 username.Redact()
90 }
91 })
92}
93
94type FakeLogger struct {
95}

Callers

nothing calls this directly

Calls 4

UserDataTypeAlias · 0.85
UDFunction · 0.70
RunMethod · 0.65
RedactMethod · 0.65

Tested by

no test coverage detected