File tree 1 file changed +42
-0
lines changed
1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,48 @@ func Benchmark_expr(b *testing.B) {
35
35
}
36
36
}
37
37
38
+ func Benchmark_filter (b * testing.B ) {
39
+ params := make (map [string ]interface {})
40
+ params ["max" ] = 50
41
+
42
+ program , err := expr .Compile (`filter(1..100, {# > max})` , expr .Env (params ))
43
+ if err != nil {
44
+ b .Fatal (err )
45
+ }
46
+
47
+ for n := 0 ; n < b .N ; n ++ {
48
+ _ , err = vm .Run (program , params )
49
+ }
50
+
51
+ if err != nil {
52
+ b .Fatal (err )
53
+ }
54
+ }
55
+
56
+ func Benchmark_access (b * testing.B ) {
57
+ type Price struct {
58
+ Value int64
59
+ }
60
+ type Env struct {
61
+ Price Price
62
+ }
63
+
64
+ program , err := expr .Compile (`Price.Value > 0` , expr .Env (Env {}))
65
+ if err != nil {
66
+ b .Fatal (err )
67
+ }
68
+
69
+ env := Env {Price : Price {Value : 1 }}
70
+
71
+ for n := 0 ; n < b .N ; n ++ {
72
+ _ , err = vm .Run (program , env )
73
+ }
74
+
75
+ if err != nil {
76
+ b .Fatal (err )
77
+ }
78
+ }
79
+
38
80
func ExampleEval () {
39
81
output , err := expr .Eval ("'hello world'" , nil )
40
82
if err != nil {
You can’t perform that action at this time.
0 commit comments