summary refs log tree commit diff
path: root/rust/benches/evaluator.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/benches/evaluator.rs')
-rw-r--r--rust/benches/evaluator.rs81
1 files changed, 54 insertions, 27 deletions
diff --git a/rust/benches/evaluator.rs b/rust/benches/evaluator.rs

index 35f7a50bce..64e13f6486 100644 --- a/rust/benches/evaluator.rs +++ b/rust/benches/evaluator.rs
@@ -14,8 +14,10 @@ #![feature(test)] use std::collections::BTreeSet; + use synapse::push::{ - evaluator::PushRuleEvaluator, Condition, EventMatchCondition, FilteredPushRules, PushRules, + evaluator::PushRuleEvaluator, Condition, EventMatchCondition, FilteredPushRules, JsonValue, + PushRules, SimpleJsonValue, }; use test::Bencher; @@ -24,9 +26,18 @@ extern crate test; #[bench] fn bench_match_exact(b: &mut Bencher) { let flattened_keys = [ - ("type".to_string(), "m.text".to_string()), - ("room_id".to_string(), "!room:server".to_string()), - ("content.body".to_string(), "test message".to_string()), + ( + "type".to_string(), + JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())), + ), + ( + "room_id".to_string(), + JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())), + ), + ( + "content.body".to_string(), + JsonValue::Value(SimpleJsonValue::Str("test message".to_string())), + ), ] .into_iter() .collect(); @@ -34,8 +45,6 @@ fn bench_match_exact(b: &mut Bencher) { let eval = PushRuleEvaluator::py_new( flattened_keys, false, - BTreeSet::new(), - false, 10, Some(0), Default::default(), @@ -49,8 +58,7 @@ fn bench_match_exact(b: &mut Bencher) { let condition = Condition::Known(synapse::push::KnownCondition::EventMatch( EventMatchCondition { key: "room_id".into(), - pattern: Some("!room:server".into()), - pattern_type: None, + pattern: "!room:server".into(), }, )); @@ -63,9 +71,18 @@ fn bench_match_exact(b: &mut Bencher) { #[bench] fn bench_match_word(b: &mut Bencher) { let flattened_keys = [ - ("type".to_string(), "m.text".to_string()), - ("room_id".to_string(), "!room:server".to_string()), - ("content.body".to_string(), "test message".to_string()), + ( + "type".to_string(), + JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())), + ), + ( + "room_id".to_string(), + JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())), + ), + ( + "content.body".to_string(), + JsonValue::Value(SimpleJsonValue::Str("test message".to_string())), + ), ] .into_iter() .collect(); @@ -73,8 +90,6 @@ fn bench_match_word(b: &mut Bencher) { let eval = PushRuleEvaluator::py_new( flattened_keys, false, - BTreeSet::new(), - false, 10, Some(0), Default::default(), @@ -88,8 +103,7 @@ fn bench_match_word(b: &mut Bencher) { let condition = Condition::Known(synapse::push::KnownCondition::EventMatch( EventMatchCondition { key: "content.body".into(), - pattern: Some("test".into()), - pattern_type: None, + pattern: "test".into(), }, )); @@ -102,9 +116,18 @@ fn bench_match_word(b: &mut Bencher) { #[bench] fn bench_match_word_miss(b: &mut Bencher) { let flattened_keys = [ - ("type".to_string(), "m.text".to_string()), - ("room_id".to_string(), "!room:server".to_string()), - ("content.body".to_string(), "test message".to_string()), + ( + "type".to_string(), + JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())), + ), + ( + "room_id".to_string(), + JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())), + ), + ( + "content.body".to_string(), + JsonValue::Value(SimpleJsonValue::Str("test message".to_string())), + ), ] .into_iter() .collect(); @@ -112,8 +135,6 @@ fn bench_match_word_miss(b: &mut Bencher) { let eval = PushRuleEvaluator::py_new( flattened_keys, false, - BTreeSet::new(), - false, 10, Some(0), Default::default(), @@ -127,8 +148,7 @@ fn bench_match_word_miss(b: &mut Bencher) { let condition = Condition::Known(synapse::push::KnownCondition::EventMatch( EventMatchCondition { key: "content.body".into(), - pattern: Some("foobar".into()), - pattern_type: None, + pattern: "foobar".into(), }, )); @@ -141,9 +161,18 @@ fn bench_match_word_miss(b: &mut Bencher) { #[bench] fn bench_eval_message(b: &mut Bencher) { let flattened_keys = [ - ("type".to_string(), "m.text".to_string()), - ("room_id".to_string(), "!room:server".to_string()), - ("content.body".to_string(), "test message".to_string()), + ( + "type".to_string(), + JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())), + ), + ( + "room_id".to_string(), + JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())), + ), + ( + "content.body".to_string(), + JsonValue::Value(SimpleJsonValue::Str("test message".to_string())), + ), ] .into_iter() .collect(); @@ -151,8 +180,6 @@ fn bench_eval_message(b: &mut Bencher) { let eval = PushRuleEvaluator::py_new( flattened_keys, false, - BTreeSet::new(), - false, 10, Some(0), Default::default(),