1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use core::time;
use std::thread;
use std::thread::Thread;
use std::time::SystemTime;
use chrono::Local;
use serde_json::json;
use serde_json::Value;
use crate::engine::{parser, runtime};
use crate::engine::node::{Node, NodeType};
use crate::engine::node::NodeType::{NNumber, NOpt};
use crate::engine::runtime::OptMap;
use crate::utils;
use crate::utils::time_util;
#[test]
fn test_parser() {
let box_node = parser::parse("a == 1 && a != 0", &OptMap::new()).unwrap();
let john = json!({
"a":1,
"name": "John Doe",
"age": {
"yes":"sadf"
},
"sex":{
"a":"i'm a",
"b":"i'm b",
},
"phones": [
"+44 1234567",
"+44 2345678"
]
});
println!("result >>>>>>>>>> = {}", box_node.eval(&john).unwrap());
}
#[test]
fn test_benchmark() {
let box_node = parser::parse("1<=2", &OptMap::new()).unwrap();
let john = json!({
"name": "John Doe",
});
let total = 10000000;
let now = SystemTime::now();
for _ in 0..total {
for _ in 0..1 {
box_node.clone();
}
}
utils::time_util::print_each_time("test_benchmark", total, now);
utils::time_util::print_qps("test_benchmark", total, now);
}