@@ -17,7 +17,7 @@ var parseTest = []string{
1717 `<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts.` ,
1818 `<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"] \xEF\xBB\xBFAn application event log entry...` ,
1919 `<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][examplePriority@32473 class="high"]` ,
20- `<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][exampleEscape@32473 text="some[data\]here"]` ,
20+ `<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][exampleEscape@32473 text="some[data\] here"]` ,
2121}
2222
2323func Test_MessageImmutable_Parse (t * testing.T ) {
@@ -171,56 +171,113 @@ Actual performance are :
171171
172172go test -cpu 1 -benchtime=10s -bench=MessageImmutable_Parse -benchmem
173173goarch: amd64
174- Benchmark_MessageImmutable_Parse_Minimal 100000000 199 ns/op 64 B/op 1 allocs/op
175- Benchmark_MessageImmutable_Parse_MessageNoSD 100000000 228 ns/op 64 B/op 1 allocs/op
176- Benchmark_MessageImmutable_Parse_KnownSDOnly 50000000 240 ns/op 64 B/op 1 allocs/op
177- Benchmark_MessageImmutable_Parse_UnkownSDOnly 100000000 238 ns/op 64 B/op 1 allocs/op
178- Benchmark_MessageImmutable_Parse_MessageAndSD 50000000 286 ns/op 64 B/op 1 allocs/op
174+ pkg: github.com/nathanaelle/syslog5424/v2
175+ Benchmark_MessageImmutable_Parse_Minimal 100000000 117 ns/op 64 B/op 1 allocs/op
176+ Benchmark_MessageImmutable_Parse_MessageNoSD 89648371 138 ns/op 64 B/op 1 allocs/op
177+ Benchmark_MessageImmutable_Parse_KnownSDOnly 87056971 140 ns/op 64 B/op 1 allocs/op
178+ Benchmark_MessageImmutable_Parse_UnkownSDOnly 88181227 140 ns/op 64 B/op 1 allocs/op
179+ Benchmark_MessageImmutable_Parse_MessageAndSD 75508340 163 ns/op 64 B/op 1 allocs/op
180+ Benchmark_MessageImmutable_Parse_Verylong 59195804 188 ns/op 64 B/op 1 allocs/op
181+ Benchmark_MessageImmutable_Parse_MaxLength 64618474 176 ns/op 64 B/op 1 allocs/op
182+ Benchmark_MessageImmutable_Parse_MessageAndSD_Then_Make_Mutable 5349686 2237 ns/op 736 B/op 24 allocs/op
179183PASS
180184
181185go test -cpu 4 -benchtime=10s -bench=MessageImmutable_Parse -benchmem
182186goarch: amd64
183- Benchmark_MessageImmutable_Parse_Minimal-4 100000000 182 ns/op 64 B/op 1 allocs/op
184- Benchmark_MessageImmutable_Parse_MessageNoSD-4 100000000 207 ns/op 64 B/op 1 allocs/op
185- Benchmark_MessageImmutable_Parse_KnownSDOnly-4 100000000 223 ns/op 64 B/op 1 allocs/op
186- Benchmark_MessageImmutable_Parse_UnkownSDOnly-4 100000000 222 ns/op 64 B/op 1 allocs/op
187- Benchmark_MessageImmutable_Parse_MessageAndSD-4 50000000 265 ns/op 64 B/op 1 allocs/op
187+ pkg: github.com/nathanaelle/syslog5424/v2
188+ Benchmark_MessageImmutable_Parse_Minimal-4 100000000 113 ns/op 64 B/op 1 allocs/op
189+ Benchmark_MessageImmutable_Parse_MessageNoSD-4 91566769 130 ns/op 64 B/op 1 allocs/op
190+ Benchmark_MessageImmutable_Parse_KnownSDOnly-4 90291741 130 ns/op 64 B/op 1 allocs/op
191+ Benchmark_MessageImmutable_Parse_UnkownSDOnly-4 92336280 129 ns/op 64 B/op 1 allocs/op
192+ Benchmark_MessageImmutable_Parse_MessageAndSD-4 76834656 154 ns/op 64 B/op 1 allocs/op
193+ Benchmark_MessageImmutable_Parse_Verylong-4 67873761 176 ns/op 64 B/op 1 allocs/op
194+ Benchmark_MessageImmutable_Parse_MaxLength-4 72529458 168 ns/op 64 B/op 1 allocs/op
195+ Benchmark_MessageImmutable_Parse_MessageAndSD_Then_Make_Mutable-4 5741421 2106 ns/op 736 B/op 24 allocs/op
188196PASS
189197
190198*/
191199
192200func Benchmark_MessageImmutable_Parse_Minimal (b * testing.B ) {
201+ var err error
202+
193203 data := []byte (`<0>1 1970-01-01T01:00:00+01:00 - - - - -` )
194204 for i := 0 ; i < b .N ; i ++ {
195- Parse (data , nil , false )
205+ _ , _ , err = Parse (data , nil , false )
206+ }
207+ if err != nil {
208+ panic (err )
196209 }
197210}
198211
199212func Benchmark_MessageImmutable_Parse_MessageNoSD (b * testing.B ) {
213+ var err error
214+
200215 data := []byte (`<165>1 2003-08-24T05:14:15.000003-07:00 192.0.2.1 myproc 8710 - - %% It's time to make the do-nuts.` )
201216 for i := 0 ; i < b .N ; i ++ {
202- Parse (data , nil , false )
217+ _ , _ , err = Parse (data , nil , false )
218+ }
219+ if err != nil {
220+ panic (err )
203221 }
204222}
205223
206224func Benchmark_MessageImmutable_Parse_KnownSDOnly (b * testing.B ) {
225+ var err error
226+
207227 data := []byte (`<0>1 1970-01-01T01:00:00Z - - - - [timeQuality tzKnown="1" isSynced="1"]` )
208228 for i := 0 ; i < b .N ; i ++ {
209- Parse (data , nil , false )
229+ _ , _ , err = Parse (data , nil , false )
230+ }
231+ if err != nil {
232+ panic (err )
210233 }
211234}
212235
213236func Benchmark_MessageImmutable_Parse_UnkownSDOnly (b * testing.B ) {
237+ var err error
238+
214239 data := []byte (`<0>1 1970-01-01T01:00:00Z - - - - [timeQualitat tzKnown="1" isSynced="1"]` )
215240 for i := 0 ; i < b .N ; i ++ {
216- Parse (data , nil , false )
241+ _ , _ , err = Parse (data , nil , false )
242+ }
243+ if err != nil {
244+ panic (err )
217245 }
218246}
219247
220248func Benchmark_MessageImmutable_Parse_MessageAndSD (b * testing.B ) {
249+ var err error
250+
221251 data := []byte (`<165>1 2003-10-11T22:14:15.003Z mymachine.example.com evntslog - ID47 [exampleSDID@32473 iut="3" eventSource="Application" eventID="1011"][examplePriority@32473 class="high"] Some log message with structured data` )
222252 for i := 0 ; i < b .N ; i ++ {
223- Parse (data , nil , false )
253+ _ , _ , err = Parse (data , nil , false )
254+ }
255+ if err != nil {
256+ panic (err )
257+ }
258+ }
259+
260+ func Benchmark_MessageImmutable_Parse_Verylong (b * testing.B ) {
261+ var err error
262+
263+ data := []byte (`<190>1 2016-02-21T01:19:11+00:00 batch6sj - - - [meta sequenceId="21881798" x-group="37051387"][origin x-service="tracking"] metascutellar conversationalist nephralgic exogenetic graphy streng outtaken acouasm amateurism prenotice Lyonese bedull antigrammatical diosphenol gastriloquial bayoneteer sweetener naggy roughhouser dighter addend sulphacid uneffectless ferroprussiate reveal Mazdaist plaudite Australasian distributival wiseman rumness Seidel topazine shahdom sinsion mesmerically pinguedinous ophthalmotonometer scuppler wound eciliate expectedly carriwitchet dictatorialism bindweb pyelitic idic atule kokoon poultryproof rusticial seedlip nitrosate splenadenoma holobenthic uneternal Phocaean epigenic doubtlessly indirection torticollar robomb adoptedly outspeak wappenschawing talalgia Goop domitic savola unstrafed carded unmagnified mythologically orchester obliteration imperialine undisobeyed galvanoplastical cycloplegia quinquennia foremean umbonal marcgraviaceous happenstance theoretical necropoles wayworn Igbira pseudoangelic raising unfrounced lamasary centaurial Japanolatry microlepidoptera` )
264+ for i := 0 ; i < b .N ; i ++ {
265+ _ , _ , err = Parse (data , nil , false )
266+ }
267+ if err != nil {
268+ panic (err )
269+ }
270+ }
271+
272+ func Benchmark_MessageImmutable_Parse_MaxLength (b * testing.B ) {
273+ var err error
274+
275+ data := []byte (`<191>1 2018-12-31T23:59:59.999999-23:59 abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabc abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdef abcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzabcdefghilmnopqrstuvzab abcdefghilmnopqrstuvzabcdefghilm [an@id key1="val1" key2="val2"][another@id key1="val1"] Some message "GET"` )
276+ for i := 0 ; i < b .N ; i ++ {
277+ _ , _ , err = Parse (data , nil , false )
278+ }
279+ if err != nil {
280+ panic (err )
224281 }
225282}
226283
0 commit comments