-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbenchmark_test.go
140 lines (125 loc) · 4.19 KB
/
benchmark_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package rfc5322
import (
"net/mail"
"testing"
)
func BenchmarkStandardSet(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSet(benchStandardSet)
}
}
func BenchmarkStandardSetGolang(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSetGolang(benchStandardSet)
}
}
func BenchmarkEncodedSet(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSet(benchEncodedSet)
}
}
func BenchmarkEncodedSetGolang(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSetGolang(benchEncodedSet)
}
}
func BenchmarkAddressListSet(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSet(benchAddressListSet)
}
}
func BenchmarkAddressListSetGolang(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSetGolang(benchAddressListSet)
}
}
func BenchmarkGroupSet(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSet(benchGroupSet)
}
}
func BenchmarkGroupSetGolang(b *testing.B) {
for i := 0; i < b.N; i++ {
parseSetGolang(benchGroupSet)
}
}
func parseSet(set []string) {
for _, addr := range set {
_, _ = ParseAddressList(addr)
}
}
func parseSetGolang(set []string) {
for _, addr := range set {
_, _ = mail.ParseAddressList(addr)
}
}
var benchStandardSet = []string{
`user@example.com`,
`John Doe <jdoe@machine.example>`,
`Mary Smith <mary@example.net>`,
`"Joe Q. Public" <john.q.public@example.com>`,
`Mary Smith <mary@x.test>`,
`jdoe@example.org`,
`Who? <one@y.test>`,
`<boss@nil.test>`,
`"Giant; \"Big\" Box" <sysservices@example.net>`,
`Pete <pete@silly.example>`,
`"Mary Smith: Personal Account" <smith@home.example>`,
`Pete(A nice \) chap) <pete(his account)@silly.test(his host)>`,
`Gogh Fir <gf@example.com>`,
`normal name <username@server.com>`,
`"comma, name" <username@server.com>`,
`name <username@server.com> (ignore comment)`,
`"Mail Robot" <>`,
`Michal Hořejšek <hořejšek@mail.com>`,
`First Last <user@domain.com >`,
`First Last <user@domain.com. >`,
`First Last <user@domain.com.>`,
`First Last <user@domain.com:25>`,
`First Last <user@[10.0.0.1]>`,
`<postmaster@[10.10.10.10]>`,
`user@domain <user@domain.com>`,
`First Last < user@domain.com>`,
`First Middle @ Last <user@domain.com>`,
`user@domain.com,`,
`First Middle "Last" <user@domain.com>`,
`First Middle Last <user@domain.com>`,
`First Middle"Last" <user@domain.com>`,
`First Middle "Last"<user@domain.com>`,
`First "Middle" "Last" <user@domain.com>`,
`First "Middle""Last" <user@domain.com>`,
}
var benchEncodedSet = []string{
`=?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>`,
`=?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>`,
`=?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>`,
`=?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se>`,
`=?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se>`,
`Nathaniel Borenstein <nsb@thumper.bellcore.com> (=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)`,
`=?UTF-8?B?PEJlemUgam3DqW5hPg==?= <user@domain.com>`,
`First Middle =?utf-8?Q?Last?= <user@domain.com>`,
`First Middle =?utf-8?Q?Last?=<user@domain.com>`,
`First =?utf-8?Q?Middle?= =?utf-8?Q?Last?= <user@domain.com>`,
`First =?utf-8?Q?Middle?==?utf-8?Q?Last?= <user@domain.com>`,
`First "Middle"=?utf-8?Q?Last?= <user@domain.com>`,
`First "Middle" =?utf-8?Q?Last?= <user@domain.com>`,
`First "Middle" =?utf-8?Q?Last?=<user@domain.com>`,
`=?UTF-8?B?PEJlemUgam3DqW5hPg==?= <user@domain.com>`,
`=?utf-8?B?6YCZ5piv5ryi5a2X55qE5LiA5YCL5L6L5a2Q?= <proton.testqa@gmail.com>`,
`=?utf-8?B?8J+MmfCfjbc=?= <user@domain.com>`,
`=?utf-8?B?8J+MmfCfjbc=?= <user@domain.com>`,
}
var benchAddressListSet = []string{
`Alice <alice@example.com>, Bob <bob@example.com>, Eve <eve@example.com>`,
`Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>`,
`name (ignore comment) <username@server.com>, (Comment as name) username2@server.com`,
`"normal name" <username@server.com>, "comma, name" <address@server.com>`,
`"comma, one" <username@server.com>, "comma, two" <address@server.com>`,
`normal name <username@server.com>, (comment)All.(around)address@(the)server.com`,
`normal name <username@server.com>, All.("comma, in comment")address@(the)server.com`,
}
var benchGroupSet = []string{
`A Group:Ed Jones <c@a.test>,joe@where.test,John <jdoe@one.test>;`,
`Undisclosed recipients:;`,
`(Empty list)(start)Hidden recipients :(nobody(that I know)) ;`,
}