@@ -14,6 +14,11 @@ async function runBenchmarks() {
1414 time : 1000 ,
1515 } ) ;
1616
17+ // Test data for TreeInterpreter benchmarks
18+ const simpleData = { foo : { bar : 'baz' } } ;
19+ const arrayData = { items : Array . from ( { length : 100 } , ( _ , i ) => ( { id : i , name : `item${ i } ` , price : i * 10 } ) ) } ;
20+ const nestedData = { level1 : { level2 : { level3 : { level4 : { value : 42 } } } } } ;
21+
1722 // Baseline parsing benchmarks
1823 bench
1924 . add ( 'Parser#single_expr' , ( ) => {
@@ -44,6 +49,41 @@ async function runBenchmarks() {
4449 } )
4550 . add ( 'Lexer#function_calls' , ( ) => {
4651 jmespath . compile ( 'sort_by(items, &price).name' ) ;
52+ } )
53+ // TreeInterpreter evaluation benchmarks
54+ . add ( 'Eval#simple_field' , ( ) => {
55+ jmespath . search ( simpleData , 'foo.bar' ) ;
56+ } )
57+ . add ( 'Eval#array_projection' , ( ) => {
58+ jmespath . search ( arrayData , 'items[*].name' ) ;
59+ } )
60+ . add ( 'Eval#filter_projection' , ( ) => {
61+ jmespath . search ( arrayData , 'items[?price > `500`].name' ) ;
62+ } )
63+ . add ( 'Eval#function_call' , ( ) => {
64+ jmespath . search ( arrayData , 'length(items)' ) ;
65+ } )
66+ . add ( 'Eval#nested_access' , ( ) => {
67+ jmespath . search ( nestedData , 'level1.level2.level3.level4.value' ) ;
68+ } )
69+ . add ( 'Eval#slice_operation' , ( ) => {
70+ jmespath . search ( arrayData , 'items[10:20]' ) ;
71+ } )
72+ // Runtime function call benchmarks
73+ . add ( 'Runtime#length_function' , ( ) => {
74+ jmespath . search ( arrayData , 'length(items)' ) ;
75+ } )
76+ . add ( 'Runtime#max_function' , ( ) => {
77+ jmespath . search ( arrayData , 'max(items[*].price)' ) ;
78+ } )
79+ . add ( 'Runtime#sort_by_function' , ( ) => {
80+ jmespath . search ( arrayData , 'sort_by(items, &price)' ) ;
81+ } )
82+ . add ( 'Runtime#map_function' , ( ) => {
83+ jmespath . search ( arrayData , 'map(&name, items)' ) ;
84+ } )
85+ . add ( 'Runtime#contains_function' , ( ) => {
86+ jmespath . search ( arrayData , 'contains(items[*].name, `"item50"`)' ) ;
4787 } ) ;
4888
4989 await bench . run ( ) ;
0 commit comments