MCPcopy Index your code
hub / github.com/foxcpp/maddy / RandomMsg

Function RandomMsg

internal/testutils/bench_delivery.go:95–110  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

93var testMailString = testHeaderString + testBodyString + strings.Repeat("A", MessageBodySize)
94
95func RandomMsg(b *testing.B) (module.MsgMetadata, textproto.Header, buffer.Buffer) {
96 IDRaw := sha1.Sum([]byte(b.Name()))
97 encodedID := hex.EncodeToString(IDRaw[:])
98
99 body := bufio.NewReader(strings.NewReader(testMailString))
100 hdr, _ := textproto.ReadHeader(body)
101 for i := 0; i < ExtraMessageHeaderFields; i++ {
102 hdr.Add("AAAAAAAAAAAA-"+strconv.Itoa(i), strings.Repeat("A", ExtraMessageHeaderFieldSize))
103 }
104 bodyBlob, _ := io.ReadAll(body)
105
106 return module.MsgMetadata{
107 DontTraceSender: true,
108 ID: encodedID,
109 }, hdr, buffer.MemoryBuffer{Slice: bodyBlob}
110}
111
112func BenchDelivery(b *testing.B, target module.DeliveryTarget, sender string, recipientTemplates []string) {
113 meta, header, body := RandomMsg(b)

Callers 1

BenchDeliveryFunction · 0.85

Calls 2

AddMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected