-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain_test.go
82 lines (65 loc) · 1.37 KB
/
main_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
package main
import (
"github.com/go-playground/validator/v10"
saddam "github.com/thedevsaddam/govalidator"
"testing"
)
func BenchmarkAsaskevich(b *testing.B) {
user := newUser()
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
validateWithAsaskevich(user)
}
}
func BenchmarkPlayground(b *testing.B) {
user := newUser()
validate := validator.New()
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
validateWithPlayground(validate, user)
}
}
func BenchmarkSaddam(b *testing.B) {
user := newUser()
rules := saddam.MapData{
"firstname": []string{"required"},
"lastname": []string{"required"},
"age": []string{"min:0", "max:130"},
"email": []string{"required", "email"},
"street": []string{"required"},
"city": []string{"required"},
"planet": []string{"required"},
"phone": []string{"required"},
}
opts := saddam.Options{
Data: user,
Rules: rules,
}
v := saddam.New(opts)
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
e := v.ValidateStruct()
if len(e) > 0 {
println(e)
}
}
}
func BenchmarkBuffalo(b *testing.B) {
user := newUser()
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
validateWithBuffalo(user)
}
}
func BenchmarkOzzo(b *testing.B) {
user := newUser()
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
validateWithOzzo(user)
}
}