You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: benches/bench.rs
+14-56Lines changed: 14 additions & 56 deletions
Original file line number
Diff line number
Diff line change
@@ -1,46 +1,34 @@
1
-
use criterion::{black_box, criterion_group, criterion_main,Criterion};
1
+
use std::hint::black_box;
2
+
3
+
use criterion::{criterion_group, criterion_main,Criterion};
2
4
use sqlformat::*;
3
5
4
6
fnsimple_query(c:&mutCriterion){
5
7
let input = "SELECT * FROM my_table WHERE id = 1";
6
8
c.bench_function("simple query", |b| {
7
-
b.iter(|| {
8
-
format(
9
-
black_box(input),
10
-
black_box(&QueryParams::None),
11
-
black_box(&FormatOptions::default()),
12
-
)
13
-
})
9
+
b.iter(|| FormatOptions::default().format(input))
14
10
});
15
11
}
16
12
17
13
fncomplex_query(c:&mutCriterion){
18
14
let input = "SELECT t1.id, t1.name, t1.title, t1.description, t2.mothers_maiden_name, t2.first_girlfriend\nFROM my_table t1 LEFT JOIN other_table t2 ON t1.id = t2.other_id WHERE t2.order BETWEEN 17 AND 30";
19
15
c.bench_function("complex query", |b| {
20
-
b.iter(|| {
21
-
format(
22
-
black_box(input),
23
-
black_box(&QueryParams::None),
24
-
black_box(&FormatOptions::default()),
25
-
)
26
-
})
16
+
b.iter(|| FormatOptions::default().format(input))
27
17
});
28
18
}
29
19
30
20
fnquery_with_named_params(c:&mutCriterion){
31
21
let input = "SELECT * FROM my_table WHERE id = :first OR id = :second OR id = :third";
let input = "SELECT\n d.uuid AS uuid,\n\td.name_of_document AS name,\n\td.slug_name AS slug,\n\td.default_contract_uuid AS default_contract_uuid,\n\ta.uuid AS parent_uuid,\n\ta.name_of_agreement AS agreement_name,\n\td.icon_name AS icon\nFROM `documents` d\nLEFT JOIN agreements a ON a.uuid = d.parent_uuid\n WHERE d.uuid = ? LIMIT 1";
0 commit comments