@@ -3,23 +3,21 @@ use cel::{Program, Value};
33use criterion:: { black_box, criterion_group, BenchmarkId , Criterion } ;
44use std:: collections:: HashMap ;
55
6- const EXPRESSIONS : [ ( & str , & str ) ; 36 ] = [
7- ( "ternary_1" , "(1 || 2 ) ? 1 : 2" ) ,
8- ( "ternary_2" , "(1 ? 2 : 3 ) ? 1 : 2" ) ,
9- ( "or_1" , "1 || 2 " ) ,
10- ( "and_1" , "1 && 2 " ) ,
11- ( "and_2" , "1 && (false ? 2 : 3)" ) ,
6+ const EXPRESSIONS : [ ( & str , & str ) ; 34 ] = [
7+ ( "ternary_1" , "(false || true ) ? 1 : 2" ) ,
8+ ( "ternary_2" , "(true ? false : true ) ? 1 : 2" ) ,
9+ ( "or_1" , "false || true " ) ,
10+ ( "and_1" , "true && false " ) ,
11+ ( "and_2" , "true && (false ? 2 : 3) > 2 " ) ,
1212 ( "number" , "1" ) ,
1313 ( "construct_list" , "[1,2,3]" ) ,
1414 ( "construct_list_1" , "[1]" ) ,
15- ( "construct_list_2" , "[1 , 2]" ) ,
15+ ( "construct_list_2" , "[a , 2]" ) ,
1616 ( "add_list" , "[1,2,3] + [4, 5, 6]" ) ,
1717 ( "list_element" , "[1,2,3][1]" ) ,
1818 ( "construct_dict" , "{1: 2, '3': '4'}" ) ,
1919 ( "add_string" , "'abc' + 'def'" ) ,
20- ( "list" , "[1,2,3, Now, ]" ) ,
2120 ( "mapexpr" , "{1 + a: 3}" ) ,
22- ( "map_merge" , "{'a': 1} + {'a': 2, 'b': 3}" ) ,
2321 ( "size_list" , "[1].size()" ) ,
2422 ( "size_list_1" , "size([1])" ) ,
2523 ( "size_str" , "'a'.size()" ) ,
@@ -67,8 +65,9 @@ pub fn criterion_benchmark(c: &mut Criterion) {
6765 let mut ctx = Context :: default ( ) ;
6866 ctx. add_variable_from_value ( "foo" , HashMap :: from ( [ ( "bar" , 1 ) ] ) ) ;
6967 ctx. add_variable_from_value ( "apple" , true ) ;
68+ ctx. add_variable_from_value ( "a" , 1 ) ;
7069 ctx. set_variable_resolver ( & Resolver ) ;
71- b. iter ( || program. execute ( & ctx) )
70+ b. iter ( || program. execute ( & ctx) . expect ( "Eval failed!" ) )
7271 } ) ;
7372 }
7473}
@@ -92,7 +91,7 @@ pub fn map_macro_benchmark(c: &mut Criterion) {
9291 let program = Program :: compile ( "list.map(x, x * 2)" ) . unwrap ( ) ;
9392 let mut ctx = Context :: default ( ) ;
9493 ctx. add_variable_from_value ( "list" , list) ;
95- b. iter ( || program. execute ( & ctx) . unwrap ( ) )
94+ b. iter ( || program. execute ( & ctx) . expect ( "Eval failed!" ) )
9695 } ) ;
9796 }
9897 group. finish ( ) ;
0 commit comments