Skip to content

Commit efc89b7

Browse files
joeybloggsjoeybloggs
authored andcommitted
Merge branch 'minor-perf-updates'
2 parents cbd857f + e534922 commit efc89b7

File tree

7 files changed

+430
-166
lines changed

7 files changed

+430
-166
lines changed

README.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package form
22
============
33
<img align="right" src="https://raw.githubusercontent.com/go-playground/form/master/logo.jpg">
4-
![Project status](https://img.shields.io/badge/version-1.6.0-green.svg)
4+
![Project status](https://img.shields.io/badge/version-1.7.0-green.svg)
55
[![Build Status](https://semaphoreci.com/api/v1/joeybloggs/form/branches/master/badge.svg)](https://semaphoreci.com/joeybloggs/form)
66
[![Coverage Status](https://coveralls.io/repos/github/go-playground/form/badge.svg?branch=master)](https://coveralls.io/github/go-playground/form?branch=master)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/form)](https://goreportcard.com/report/github.com/go-playground/form)
@@ -268,26 +268,26 @@ NOTE: the 1 allocation and B/op in the first 4 decodes is actually the struct al
268268
go test -bench=. -benchmem=true
269269

270270
PASS
271-
BenchmarkSimpleUserDecodeStruct-8 5000000 293 ns/op 64 B/op 1 allocs/op
272-
BenchmarkSimpleUserDecodeStructParallel-8 20000000 112 ns/op 64 B/op 1 allocs/op
273-
BenchmarkSimpleUserEncodeStruct-8 2000000 808 ns/op 466 B/op 7 allocs/op
274-
BenchmarkSimpleUserEncodeStructParallel-8 5000000 278 ns/op 466 B/op 7 allocs/op
275-
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8 2000000 965 ns/op 96 B/op 1 allocs/op
276-
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8 5000000 284 ns/op 96 B/op 1 allocs/op
277-
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8 300000 4349 ns/op 2913 B/op 32 allocs/op
278-
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8 1000000 1469 ns/op 2913 B/op 32 allocs/op
279-
BenchmarkComplexArrayDecodeStructAllTypes-8 100000 20608 ns/op 6776 B/op 159 allocs/op
280-
BenchmarkComplexArrayDecodeStructAllTypesParallel-8 200000 6265 ns/op 6776 B/op 159 allocs/op
281-
BenchmarkComplexArrayEncodeStructAllTypes-8 100000 17198 ns/op 7192 B/op 154 allocs/op
282-
BenchmarkComplexArrayEncodeStructAllTypesParallel-8 300000 5157 ns/op 7191 B/op 154 allocs/op
283-
BenchmarkComplexMapDecodeStructAllTypes-8 50000 34637 ns/op 20869 B/op 241 allocs/op
284-
BenchmarkComplexMapDecodeStructAllTypesParallel-8 100000 12095 ns/op 20870 B/op 241 allocs/op
285-
BenchmarkComplexMapEncodeStructAllTypes-8 100000 18193 ns/op 7095 B/op 177 allocs/op
286-
BenchmarkComplexMapEncodeStructAllTypesParallel-8 300000 5651 ns/op 7096 B/op 177 allocs/op
287-
BenchmarkDecodeNestedStruct-8 300000 5537 ns/op 2064 B/op 37 allocs/op
288-
BenchmarkDecodeNestedStructParallel-8 1000000 1932 ns/op 2064 B/op 37 allocs/op
289-
BenchmarkEncodeNestedStruct-8 500000 2956 ns/op 848 B/op 26 allocs/op
290-
BenchmarkEncodeNestedStructParallel-8 1000000 1168 ns/op 848 B/op 26 allocs/op
271+
BenchmarkSimpleUserDecodeStruct-8 5000000 299 ns/op 64 B/op 1 allocs/op
272+
BenchmarkSimpleUserDecodeStructParallel-8 20000000 106 ns/op 64 B/op 1 allocs/op
273+
BenchmarkSimpleUserEncodeStruct-8 2000000 825 ns/op 466 B/op 7 allocs/op
274+
BenchmarkSimpleUserEncodeStructParallel-8 5000000 301 ns/op 466 B/op 7 allocs/op
275+
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8 2000000 901 ns/op 96 B/op 1 allocs/op
276+
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8 5000000 283 ns/op 96 B/op 1 allocs/op
277+
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8 300000 4302 ns/op 2912 B/op 32 allocs/op
278+
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8 1000000 1542 ns/op 2913 B/op 32 allocs/op
279+
BenchmarkComplexArrayDecodeStructAllTypes-8 100000 18125 ns/op 2730 B/op 135 allocs/op
280+
BenchmarkComplexArrayDecodeStructAllTypesParallel-8 300000 6178 ns/op 2734 B/op 135 allocs/op
281+
BenchmarkComplexArrayEncodeStructAllTypes-8 100000 17738 ns/op 7190 B/op 154 allocs/op
282+
BenchmarkComplexArrayEncodeStructAllTypesParallel-8 300000 5360 ns/op 7192 B/op 154 allocs/op
283+
BenchmarkComplexMapDecodeStructAllTypes-8 50000 28476 ns/op 7567 B/op 163 allocs/op
284+
BenchmarkComplexMapDecodeStructAllTypesParallel-8 200000 9849 ns/op 7604 B/op 163 allocs/op
285+
BenchmarkComplexMapEncodeStructAllTypes-8 100000 18424 ns/op 7097 B/op 177 allocs/op
286+
BenchmarkComplexMapEncodeStructAllTypesParallel-8 300000 5852 ns/op 7096 B/op 177 allocs/op
287+
BenchmarkDecodeNestedStruct-8 200000 5199 ns/op 1040 B/op 31 allocs/op
288+
BenchmarkDecodeNestedStructParallel-8 1000000 1713 ns/op 1040 B/op 31 allocs/op
289+
BenchmarkEncodeNestedStruct-8 500000 3025 ns/op 848 B/op 26 allocs/op
290+
BenchmarkEncodeNestedStructParallel-8 1000000 1096 ns/op 848 B/op 26 allocs/op
291291
```
292292

293293
Competitor benchmarks can be found [here](https://github.com/go-playground/form/blob/master/benchmarks/benchmarks.md)

benchmarks/benchmarks.md

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22

33
### go-playground/form
44
```go
5-
BenchmarkSimpleUserDecodeStruct-8 5000000 293 ns/op 64 B/op 1 allocs/op
6-
BenchmarkSimpleUserDecodeStructParallel-8 20000000 112 ns/op 64 B/op 1 allocs/op
7-
BenchmarkSimpleUserEncodeStruct-8 2000000 808 ns/op 466 B/op 7 allocs/op
8-
BenchmarkSimpleUserEncodeStructParallel-8 5000000 278 ns/op 466 B/op 7 allocs/op
9-
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8 2000000 965 ns/op 96 B/op 1 allocs/op
10-
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8 5000000 284 ns/op 96 B/op 1 allocs/op
11-
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8 300000 4349 ns/op 2913 B/op 32 allocs/op
12-
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8 1000000 1469 ns/op 2913 B/op 32 allocs/op
13-
BenchmarkComplexArrayDecodeStructAllTypes-8 100000 20608 ns/op 6776 B/op 159 allocs/op
14-
BenchmarkComplexArrayDecodeStructAllTypesParallel-8 200000 6265 ns/op 6776 B/op 159 allocs/op
15-
BenchmarkComplexArrayEncodeStructAllTypes-8 100000 17198 ns/op 7192 B/op 154 allocs/op
16-
BenchmarkComplexArrayEncodeStructAllTypesParallel-8 300000 5157 ns/op 7191 B/op 154 allocs/op
17-
BenchmarkComplexMapDecodeStructAllTypes-8 50000 34637 ns/op 20869 B/op 241 allocs/op
18-
BenchmarkComplexMapDecodeStructAllTypesParallel-8 100000 12095 ns/op 20870 B/op 241 allocs/op
19-
BenchmarkComplexMapEncodeStructAllTypes-8 100000 18193 ns/op 7095 B/op 177 allocs/op
20-
BenchmarkComplexMapEncodeStructAllTypesParallel-8 300000 5651 ns/op 7096 B/op 177 allocs/op
21-
BenchmarkDecodeNestedStruct-8 300000 5537 ns/op 2064 B/op 37 allocs/op
22-
BenchmarkDecodeNestedStructParallel-8 1000000 1932 ns/op 2064 B/op 37 allocs/op
23-
BenchmarkEncodeNestedStruct-8 500000 2956 ns/op 848 B/op 26 allocs/op
24-
BenchmarkEncodeNestedStructParallel-8 1000000 1168 ns/op 848 B/op 26 allocs/op
5+
BenchmarkSimpleUserDecodeStruct-8 5000000 299 ns/op 64 B/op 1 allocs/op
6+
BenchmarkSimpleUserDecodeStructParallel-8 20000000 106 ns/op 64 B/op 1 allocs/op
7+
BenchmarkSimpleUserEncodeStruct-8 2000000 825 ns/op 466 B/op 7 allocs/op
8+
BenchmarkSimpleUserEncodeStructParallel-8 5000000 301 ns/op 466 B/op 7 allocs/op
9+
BenchmarkPrimitivesDecodeStructAllPrimitivesTypes-8 2000000 901 ns/op 96 B/op 1 allocs/op
10+
BenchmarkPrimitivesDecodeStructAllPrimitivesTypesParallel-8 5000000 283 ns/op 96 B/op 1 allocs/op
11+
BenchmarkPrimitivesEncodeStructAllPrimitivesTypes-8 300000 4302 ns/op 2912 B/op 32 allocs/op
12+
BenchmarkPrimitivesEncodeStructAllPrimitivesTypesParallel-8 1000000 1542 ns/op 2913 B/op 32 allocs/op
13+
BenchmarkComplexArrayDecodeStructAllTypes-8 100000 18125 ns/op 2730 B/op 135 allocs/op
14+
BenchmarkComplexArrayDecodeStructAllTypesParallel-8 300000 6178 ns/op 2734 B/op 135 allocs/op
15+
BenchmarkComplexArrayEncodeStructAllTypes-8 100000 17738 ns/op 7190 B/op 154 allocs/op
16+
BenchmarkComplexArrayEncodeStructAllTypesParallel-8 300000 5360 ns/op 7192 B/op 154 allocs/op
17+
BenchmarkComplexMapDecodeStructAllTypes-8 50000 28476 ns/op 7567 B/op 163 allocs/op
18+
BenchmarkComplexMapDecodeStructAllTypesParallel-8 200000 9849 ns/op 7604 B/op 163 allocs/op
19+
BenchmarkComplexMapEncodeStructAllTypes-8 100000 18424 ns/op 7097 B/op 177 allocs/op
20+
BenchmarkComplexMapEncodeStructAllTypesParallel-8 300000 5852 ns/op 7096 B/op 177 allocs/op
21+
BenchmarkDecodeNestedStruct-8 200000 5199 ns/op 1040 B/op 31 allocs/op
22+
BenchmarkDecodeNestedStructParallel-8 1000000 1713 ns/op 1040 B/op 31 allocs/op
23+
BenchmarkEncodeNestedStruct-8 500000 3025 ns/op 848 B/op 26 allocs/op
24+
BenchmarkEncodeNestedStructParallel-8 1000000 1096 ns/op 848 B/op 26 allocs/op
2525
```
2626

2727
### gorilla/schema
@@ -45,21 +45,13 @@ No Encoder Support At This Time
4545

4646
### monoculum/formam
4747
```go
48-
BenchmarkSimpleUserStructFormam-8 500000 3713 ns/op 264 B/op 19 allocs/op
49-
BenchmarkSimpleUserStructFormamParallel-8 1000000 1017 ns/op 264 B/op 19 allocs/op
50-
BenchmarkPrimitivesStructAllPrimitivesFormamTypes-8 100000 12197 ns/op 1280 B/op 134 allocs/op
51-
BenchmarkPrimitivesStructAllPrimitivesTypesFormamParallel-8 500000 3905 ns/op 1280 B/op 134 allocs/op
52-
BenchmarkComplexArrayStructAllTypesFormam-8 30000 58650 ns/op 6371 B/op 522 allocs/op
53-
BenchmarkComplexArrayStructAllTypesFormamParallel-8 100000 19046 ns/op 6349 B/op 521 allocs/op
54-
BenchmarkComplexMapStructAllTypesFormam-8 --- FAIL: BenchmarkComplexMapStructAllTypesFormam-8
55-
formam_test.go:142: formam: the key with uint16 type (map[uint16]uint16) in the path Uint16.0 should implements the TextUnmarshaler interface for to can decode it
56-
BenchmarkComplexMapStructAllTypesFormamParallel-8 --- FAIL: BenchmarkComplexMapStructAllTypesFormamParallel-8
57-
formam_test.go:158: formam: the key with int type (map[int]int) in the path Int.0 should implements the TextUnmarshaler interface for to can decode it
58-
BenchmarkArrayMapNestedStructFormam-8 --- FAIL: BenchmarkArrayMapNestedStructFormam-8
59-
formam_test.go:174: formam: not supported type for field "Value" in path "NestedPtrArray[1].Value"
60-
BenchmarkArrayMapNestedStructFormamParallel-8 --- FAIL: BenchmarkArrayMapNestedStructFormamParallel-8
61-
formam_test.go:189: formam: not supported type for field "Value" in path "NestedPtrArray[0].Value"
62-
No Encoder Support At This Time
48+
BenchmarkSimpleUserStructFormam-8 500000 2823 ns/op 232 B/op 16 allocs/op
49+
BenchmarkSimpleUserStructFormamParallel-8 2000000 825 ns/op 232 B/op 16 allocs/op
50+
BenchmarkPrimitivesStructAllPrimitivesFormamTypes-8 200000 9179 ns/op 1088 B/op 121 allocs/op
51+
BenchmarkPrimitivesStructAllPrimitivesTypesFormamParallel-8 500000 2949 ns/op 1088 B/op 121 allocs/op
52+
BenchmarkComplexArrayStructAllTypesFormam-8 30000 41381 ns/op 5668 B/op 496 allocs/op
53+
BenchmarkComplexArrayStructAllTypesFormamParallel-8 100000 14455 ns/op 5705 B/op 498 allocs/op
54+
BenchmarkComplexMapStructAllTypesFormam-8 panic: reflect: reflect.Value.Set using unaddressable value
6355
```
6456

6557
### ajg/form

benchmarks/formam_test.go

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package benchmarks
22

33
import (
4-
"net/url"
54
"testing"
65

76
"github.com/monoculum/formam"
@@ -95,39 +94,10 @@ func BenchmarkComplexArrayStructAllTypesFormamParallel(b *testing.B) {
9594

9695
// Complex Map ALL types
9796

98-
func getComplexMapStructValuesFormam() url.Values {
99-
return url.Values{
100-
"String.key": []string{"value"},
101-
"StringPtr.key": []string{"value"},
102-
"Int.0": []string{"1"},
103-
"IntPtr.0": []string{"1"},
104-
"Int8.0": []string{"1"},
105-
"Int8Ptr.0": []string{"1"},
106-
"Int16.0": []string{"1"},
107-
"Int16Ptr.0": []string{"1"},
108-
"Int32.0": []string{"1"},
109-
"Int32Ptr.0": []string{"1"},
110-
"Int64.0": []string{"1"},
111-
"Int64Ptr.0": []string{"1"},
112-
"Uint.0": []string{"1"},
113-
"UintPtr.0": []string{"1"},
114-
"Uint8.0": []string{"1"},
115-
"Uint8Ptr.0": []string{"1"},
116-
"Uint16.0": []string{"1"},
117-
"Uint16Ptr.0": []string{"1"},
118-
"Uint32.0": []string{"1"},
119-
"Uint32Ptr.0": []string{"1"},
120-
"Uint64.0": []string{"1"},
121-
"Uint64Ptr.0": []string{"1"},
122-
"NestedInt.1.2": []string{"3"},
123-
"NestedIntPtr.1.2": []string{"3"},
124-
}
125-
}
126-
12797
func BenchmarkComplexMapStructAllTypesFormam(b *testing.B) {
12898
// b.Log("Formam only supports map key of string at this time")
12999
// b.SkipNow()
130-
values := getComplexMapStructValuesFormam()
100+
values := getComplexMapStructValues()
131101

132102
b.ReportAllocs()
133103
for n := 0; n < b.N; n++ {
@@ -141,7 +111,7 @@ func BenchmarkComplexMapStructAllTypesFormam(b *testing.B) {
141111
func BenchmarkComplexMapStructAllTypesFormamParallel(b *testing.B) {
142112
// b.Log("Formam only supports map key of string at this time")
143113
// b.SkipNow()
144-
values := getComplexMapStructValuesFormam()
114+
values := getComplexMapStructValues()
145115

146116
b.ReportAllocs()
147117
b.RunParallel(func(pb *testing.PB) {

0 commit comments

Comments
 (0)