@@ -13,6 +13,10 @@ const ctx = {
1313 f : { g : [ x => x + 1 ] } , h : 10 , i : { j : 20 }
1414} ;
1515
16+ // CEL-compatible expression (CEL uses BigInt, no function calls on array elements)
17+ const celExpr = `a + b * c - d / e + f.g[0] + i.j` ;
18+ const celCtx = { a : 1n , b : 2n , c : 3n , d : 4n , e : 5n , f : { g : [ 11n ] } , i : { j : 20n } } ;
19+
1620const bench = ( name , fn ) => {
1721 // Warmup
1822 for ( let i = 0 ; i < 1000 ; i ++ ) fn ( ) ;
@@ -121,6 +125,13 @@ async function run() {
121125 results . parse [ 'angular-expr' ] = bench ( 'angular-expr' , ( ) => ae . compile ( expr ) ) ;
122126 } catch ( e ) { console . log ( 'angular-expr: SKIP -' , e . message ) ; }
123127
128+ // @marcbachmann /cel-js
129+ try {
130+ const { parse : celParse } = await cdn ( '@marcbachmann/cel-js' ) ;
131+ celParse ( celExpr ) ;
132+ results . parse [ 'cel-js' ] = bench ( 'cel-js' , ( ) => celParse ( celExpr ) ) ;
133+ } catch ( e ) { console . log ( 'cel-js: SKIP -' , e . message ) ; }
134+
124135 console . log ( '\n=== EVAL ===\n' ) ;
125136
126137 // subscript compile (js)
@@ -188,6 +199,14 @@ async function run() {
188199 results . eval [ 'angular-expr' ] = bench ( 'angular-expr' , ( ) => fn ( ctx ) ) ;
189200 } catch ( e ) { console . log ( 'angular-expr: SKIP -' , e . message ) ; }
190201
202+ // @marcbachmann /cel-js
203+ try {
204+ const { parse : celParse } = await cdn ( '@marcbachmann/cel-js' ) ;
205+ const celFn = celParse ( celExpr ) ;
206+ celFn ( celCtx ) ;
207+ results . eval [ 'cel-js' ] = bench ( 'cel-js' , ( ) => celFn ( celCtx ) ) ;
208+ } catch ( e ) { console . log ( 'cel-js: SKIP -' , e . message ) ; }
209+
191210 // Summary
192211 console . log ( '\n=== SUMMARY ===\n' ) ;
193212
0 commit comments