|
| 1 | +use argusdb::bench_utils::{save_profile, start_profiling}; |
1 | 2 | use argusdb::db::DB; |
2 | 3 | use argusdb::query::{BinaryOperator, Expression, LogicalPlan, execute_plan}; |
3 | 4 | use criterion::{BenchmarkId, Criterion, Throughput, criterion_group, criterion_main}; |
@@ -42,6 +43,16 @@ fn generate_query_plan( |
42 | 43 | } |
43 | 44 |
|
44 | 45 | fn insertion_benchmark(c: &mut Criterion) { |
| 46 | + let profile_path = std::env::var("ARGUS_PROFILE").ok().map(|p| { |
| 47 | + if p.is_empty() { |
| 48 | + "insertion_profile.pb".to_string() |
| 49 | + } else { |
| 50 | + format!("insertion_{}", p) |
| 51 | + } |
| 52 | + }); |
| 53 | + |
| 54 | + let guard = start_profiling(&profile_path); |
| 55 | + |
45 | 56 | let mut group = c.benchmark_group("insertion"); |
46 | 57 | group.sample_size(10); |
47 | 58 | let max_docs = 10_000; |
@@ -76,9 +87,21 @@ fn insertion_benchmark(c: &mut Criterion) { |
76 | 87 | } |
77 | 88 |
|
78 | 89 | group.finish(); |
| 90 | + |
| 91 | + save_profile(guard, &profile_path); |
79 | 92 | } |
80 | 93 |
|
81 | 94 | fn query_benchmark(c: &mut Criterion) { |
| 95 | + let profile_path = std::env::var("ARGUS_PROFILE").ok().map(|p| { |
| 96 | + if p.is_empty() { |
| 97 | + "query_profile.pb".to_string() |
| 98 | + } else { |
| 99 | + format!("query_{}", p) |
| 100 | + } |
| 101 | + }); |
| 102 | + |
| 103 | + let guard = start_profiling(&profile_path); |
| 104 | + |
82 | 105 | let mut group = c.benchmark_group("query"); |
83 | 106 | group.sample_size(10); |
84 | 107 | let num_docs = 10_000; |
@@ -131,6 +154,8 @@ fn query_benchmark(c: &mut Criterion) { |
131 | 154 | } |
132 | 155 |
|
133 | 156 | group.finish(); |
| 157 | + |
| 158 | + save_profile(guard, &profile_path); |
134 | 159 | } |
135 | 160 |
|
136 | 161 | criterion_group!(benches, insertion_benchmark, query_benchmark); |
|
0 commit comments