File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -119,3 +119,49 @@ func Benchmark_largeStructAccess(b *testing.B) {
119119 b .Fatal (err )
120120 }
121121}
122+
123+ func Benchmark_largeNestedStructAccess (b * testing.B ) {
124+ type Env struct {
125+ Inner struct {
126+ Data [1024 * 1024 * 10 ]byte
127+ Field int
128+ }
129+ }
130+
131+ program , err := expr .Compile (`Inner.Field > 0 && Inner.Field > 1 && Inner.Field < 20` , expr .Env (Env {}))
132+ if err != nil {
133+ b .Fatal (err )
134+ }
135+
136+ env := Env {}
137+ env .Inner .Field = 21
138+
139+ for n := 0 ; n < b .N ; n ++ {
140+ _ , err = vm .Run (program , & env )
141+ }
142+
143+ if err != nil {
144+ b .Fatal (err )
145+ }
146+ }
147+
148+ func Benchmark_largeNestedArrayAccess (b * testing.B ) {
149+ type Env struct {
150+ Data [1 ][1024 * 1024 * 10 ]byte
151+ }
152+
153+ program , err := expr .Compile (`Data[0][0] > 0` , expr .Env (Env {}))
154+ if err != nil {
155+ b .Fatal (err )
156+ }
157+
158+ env := Env {}
159+
160+ for n := 0 ; n < b .N ; n ++ {
161+ _ , err = vm .Run (program , & env )
162+ }
163+
164+ if err != nil {
165+ b .Fatal (err )
166+ }
167+ }
You can’t perform that action at this time.
0 commit comments