Skip to content

Commit 1888db0

Browse files
committed
Add len() benchmark
1 parent cffbb1f commit 1888db0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bench_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,25 @@ func Benchmark_filter(b *testing.B) {
9898
}
9999
}
100100

101+
func Benchmark_len(b *testing.B) {
102+
program, err := expr.Compile(`len(1..100)`)
103+
if err != nil {
104+
b.Fatal(err)
105+
}
106+
107+
var out interface{}
108+
for n := 0; n < b.N; n++ {
109+
out, err = vm.Run(program, nil)
110+
}
111+
112+
if err != nil {
113+
b.Fatal(err)
114+
}
115+
if out.(int) != 100 {
116+
b.Fail()
117+
}
118+
}
119+
101120
func Benchmark_access(b *testing.B) {
102121
type Price struct {
103122
Value int

0 commit comments

Comments
 (0)