Repository: ALU-Schumacher/AUDITOR (language: rust)

Issue:
Benchmarks: Make number of records configurable via config
Currently, the benchmarking code provides several functions (`real_case_record_size_*`) that run the benchmarks with different numbers of records. If one wants to switch to a different number of records, the call to the function needs to be changed and the benchmark recompiled.

It would be nicer if we could specify the number of records (and maybe other parameters that are different in these functions) inside the config. This way, one can run different benchmarks without recompiling. Also, we then can use this to run a benchmark with a very small number of records for the CI test (see #774)


Discussion / hints:

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4bcbe33ed..8add17ac7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - Apel plugin: Add TRACE level for logging ([@dirksammel](https://github.com/dirksammel))
 - Apel plugin: Re-use records fetched for sync message for individual jobs reporting ([@dirksammel](https://github.com/dirksammel))
 - Auditor: Use workspace dependencies ([@dirksammel](https://github.com/dirksammel))
+- Benchmark: Add `num_of_records` and `sample size` config fields for benchmark script ([@raghuvar-vijay](https://github.com/raghuvar-vijay))
 - Dependencies: Update actix-web from 4.5.1 to 4.6.0 ([@dirksammel](https://github.com/dirksammel))
 - Dependencies: Update anyhow from 1.0.82 to 1.0.86 ([@dirksammel](https://github.com/dirksammel))
 - Slurm collector: Remove fields `collector_addr` and `collector_port` in settings struct ([@raghuvar-vijay](https://github.com/raghuvar-vijay))
diff --git a/auditor/benches/benchmark_with_http_request.rs b/auditor/benches/benchmark_with_http_request.rs
index 207ae5a08..385a2d52f 100644
--- a/auditor/benches/benchmark_with_http_request.rs
+++ b/auditor/benches/benchmark_with_http_request.rs
@@ -13,8 +13,7 @@ use fake::{Fake, Faker};
 use rand::Rng;
 use std::collections::HashMap;
 
-use criterion::{black_box, criterion_group, criterion_main, Criterion};
-use std::time::Duration;
+use criterion::{criterion_group, criterion_main, Criterion};
 use tokio::runtime::Runtime;
 
 use rand_distr::Normal;
@@ -129,58 +128,20 @@ fn generate_stop_time_duration<R: Rng>(rng: &mut R, normal: &Normal<f64>) -> i64
     random_stop_time_duration.abs()
 }
 
-fn worst_case_insertion_benchmark_with_client(c: &mut Criterion) {
-    let mut group = c.benchmark_group("Insertion of records");
+fn benchmark_record_query_from_auditor(c: &mut Criterion) {
+    let mut group = c.benchmark_group("benchmark_record_query_from_auditor");
 
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-
-    group.measurement_time(Duration::from_secs(30));
-
-    group.sample_size(100);
-
-    group.bench_function("inserting_1000_records", |b| {
-        let records: Vec<RecordTest> = (0..1000).map(|_| Faker.fake()).collect();
-
-        let test_cases: Vec<RecordAdd> = records
-            .iter()
-            .cloned()
-            .map(RecordAdd::try_from)
-            .map(Result::unwrap)
-            .collect();
-
-        b.iter(|| rt.block_on(async { client.bulk_insert(black_box(&test_cases)).await }))
-    });
-
-    group.bench_function("inserting_100_records", |b| {
-        let records: Vec<RecordTest> = (0..100).map(|_| Faker.fake()).collect();
-
-        let test_cases: Vec<RecordAdd> = records
-            .iter()
-            .cloned()
-            .map(RecordAdd::try_from)
-            .map(Result::unwrap)
-            .collect();
-
-        b.iter(|| rt.block_on(async { client.bulk_insert(black_box(&test_cases)).await }))
-    });
-
-    group.finish();
-}
-
-fn real_case_record_size_10_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("real_case_query_record_size_10_000");
+    let configuration = get_configuration().expect("Failed to read configuration.");
 
     let rt = Runtime::new().unwrap();
 
     let client = start_client().unwrap();
 
-    group.sample_size(3000);
+    group.sample_size(configuration.sample_size);
 
     let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
 
-    let num: i64 = 10_000i64;
+    let num: i64 = configuration.num_of_records;
 
     let increment: i64 = 315i64;
 
@@ -202,131 +163,7 @@ fn real_case_record_size_10_000(c: &mut Criterion) {
     let get_all_records =
         QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
 
-    group.bench_function("queyring_all_100_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let query_start_time = start_time.checked_add_days(Days::new(100)).unwrap();
-
-    let stop_time = query_start_time.checked_add_days(Days::new(120)).unwrap();
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let time_and_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_and_site_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let time_meta_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async { time_meta_component_query.clone().get(client.clone()).await })
-        })
-    });
-
-    let time_two_meta_and_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_two_meta_and_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                time_two_meta_and_component_query
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
-fn real_case_record_size_50_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("real_case_query_record_size_50_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-
-    group.sample_size(3000);
-
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 50_000i64;
-
-    let increment: i64 = 630i64;
-
-    let _ = rt.block_on(async { insert_records(num, increment).await });
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists.get(client.clone()).await;
-        assert!(response.unwrap().len() == 50000)
-    });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    group.bench_function("queyring_all_50_000_records", |b| {
+    group.bench_function("queyring_all_records", |b| {
         b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
     });
 
@@ -417,690 +254,7 @@ fn real_case_record_size_50_000(c: &mut Criterion) {
     });
 }
 
-fn real_case_record_size_100_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("real_case_query_record_size_100_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-
-    group.sample_size(3000);
-
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 100_000i64;
-
-    let increment: i64 = 315i64;
-
-    let _ = rt.block_on(async { insert_records(num, increment).await });
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists.get(client.clone()).await;
-        assert!(response.unwrap().len() == 100_000)
-    });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    group.bench_function("queyring_all_100_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let query_start_time = start_time.checked_add_days(Days::new(100)).unwrap();
-
-    let stop_time = query_start_time.checked_add_days(Days::new(120)).unwrap();
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let time_and_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_and_site_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let time_meta_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async { time_meta_component_query.clone().get(client.clone()).await })
-        })
-    });
-
-    let time_two_meta_and_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_two_meta_and_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                time_two_meta_and_component_query
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
-fn real_case_record_size_1_000_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("real_case_query_record_size_1_000_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-
-    group.sample_size(3000);
-
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 100_000i64;
-
-    let increment: i64 = 31i64;
-
-    let _ = rt.block_on(async { insert_records(num, increment).await });
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists
-            .clone()
-            .get(client.clone())
-            .await;
-
-        assert!(response.unwrap().len() == 1_000_000)
-    });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    group.bench_function("queyring_all_1_000_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let query_start_time = start_time.checked_add_days(Days::new(100)).unwrap();
-
-    let stop_time = query_start_time.checked_add_days(Days::new(120)).unwrap();
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let time_and_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_and_site_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let time_meta_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async { time_meta_component_query.clone().get(client.clone()).await })
-        })
-    });
-
-    let time_two_meta_and_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_two_meta_and_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                time_two_meta_and_component_query
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
-fn real_case_record_size_10_000_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("real_case_query_record_size_10_000_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-
-    group.sample_size(3000);
-
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 10_000_000i64;
-
-    let increment: i64 = 3i64;
-
-    let _ = rt.block_on(async { insert_records(num, increment).await });
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists
-            .clone()
-            .get(client.clone())
-            .await;
-
-        assert!(response.unwrap().len() == 100_000)
-    });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    group.bench_function("queyring_all_10_000_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let query_start_time = start_time.checked_add_days(Days::new(100)).unwrap();
-
-    let stop_time = query_start_time.checked_add_days(Days::new(120)).unwrap();
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let time_and_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_and_site_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let time_meta_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("site_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async { time_meta_component_query.clone().get(client.clone()).await })
-        })
-    });
-
-    let time_two_meta_and_component_query = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_two_meta_and_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                time_two_meta_and_component_query
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
-fn worst_case_record_size_100_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("worst_case_query_record_size_100_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 100_000i64;
-
-    let _ = rt.block_on(async { insert_worst_case_records(num).await });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists
-            .clone()
-            .get(client.clone())
-            .await;
-
-        assert!(response.unwrap().len() == 100_000)
-    });
-
-    group.bench_function("queyring_started_since_from_100_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let stop_time = start_time.checked_add_days(Days::new(100));
-
-    let record_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.unwrap().into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { record_site_query.clone().get(client.clone()).await }))
-    });
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.unwrap().into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let filter_on_time_meta_components = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.unwrap().into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                filter_on_time_meta_components
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
-fn worst_case_record_size_1_000_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("worst_case_query_record_size_100_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 1_000_000i64;
-
-    let _ = rt.block_on(async { insert_worst_case_records(num).await });
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists
-            .clone()
-            .get(client.clone())
-            .await;
-
-        assert!(response.unwrap().len() == 100_000)
-    });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    group.bench_function("queyring_started_since_from_100_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let stop_time = start_time.checked_add_days(Days::new(100));
-
-    let record_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "site_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.unwrap().into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { record_site_query.clone().get(client.clone()).await }))
-    });
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.unwrap().into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let filter_on_time_meta_components = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.unwrap().into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                filter_on_time_meta_components
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
-fn worst_case_record_size_10_000_000(c: &mut Criterion) {
-    let mut group = c.benchmark_group("worst_case_query_record_size_100_000");
-
-    let rt = Runtime::new().unwrap();
-
-    let client = start_client().unwrap();
-
-    group.measurement_time(Duration::from_secs(30));
-
-    let start_time: DateTime<Utc> = Utc.with_ymd_and_hms(2023, 1, 1, 0, 0, 0).unwrap();
-
-    let num: i64 = 10_000_000i64;
-
-    let _ = rt.block_on(async { insert_worst_case_records(num).await });
-
-    rt.block_on(async {
-        let response = client.health_check().await;
-
-        assert!(response)
-    });
-
-    rt.block_on(async {
-        let check_if_all_records_exists =
-            QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-        let response = check_if_all_records_exists
-            .clone()
-            .get(client.clone())
-            .await;
-
-        assert!(response.unwrap().len() == 100_000)
-    });
-
-    let get_all_records =
-        QueryBuilder::new().with_start_time(Operator::default().gte(start_time.into()));
-
-    group.bench_function("queyring_started_since_from_100_000_records", |b| {
-        b.iter(|| rt.block_on(async { get_all_records.clone().get(client.clone()).await }))
-    });
-
-    let stop_time = start_time.checked_add_days(Days::new(100));
-
-    let record_site_query = QueryBuilder::new()
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.unwrap().into()),
-        );
-
-    group.bench_function("querying_one_site_id_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { record_site_query.clone().get(client.clone()).await }))
-    });
-
-    let time_range_query = QueryBuilder::new().with_start_time(
-        Operator::default()
-            .gte(start_time.into())
-            .lt(stop_time.unwrap().into()),
-    );
-
-    group.bench_function("querying_within_a_time_range", |b| {
-        b.iter(|| rt.block_on(async { time_range_query.clone().get(client.clone()).await }))
-    });
-
-    let count: u8 = 6u8;
-    let component_query = QueryBuilder::new().with_component_query(
-        ComponentQuery::new()
-            .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-    );
-
-    group.bench_function("querying_records_with_component_name", |b| {
-        b.iter(|| rt.block_on(async { component_query.clone().get(client.clone()).await }))
-    });
-
-    let filter_on_time_meta_components = QueryBuilder::new()
-        .with_start_time(
-            Operator::default()
-                .gte(start_time.into())
-                .lt(stop_time.unwrap().into()),
-        )
-        .with_meta_query(MetaQuery::new().meta_operator(
-            "group_id".to_string(),
-            MetaOperator::default().contains("group_1".to_string()),
-        ))
-        .with_component_query(
-            ComponentQuery::new()
-                .component_operator("cpu".to_string(), Operator::default().equals(count.into())),
-        );
-
-    group.bench_function("querying_with_time_meta_component_fields", |b| {
-        b.iter(|| {
-            rt.block_on(async {
-                filter_on_time_meta_components
-                    .clone()
-                    .get(client.clone())
-                    .await
-            })
-        })
-    });
-}
-
 // Change here to specify the function you would like to benchmark. Please specify only one
 // function name at a time.
-criterion_group!(benches, real_case_record_size_10_000);
+criterion_group!(benches, benchmark_record_query_from_auditor);
 criterion_main!(benches);
diff --git a/auditor/benches/configuration.rs b/auditor/benches/configuration.rs
index d124c52bb..090aed76c 100644
--- a/auditor/benches/configuration.rs
+++ b/auditor/benches/configuration.rs
@@ -6,12 +6,24 @@ pub struct AuditorSettings {
     pub addr: String,
     #[serde(deserialize_with = "deserialize_number_from_string")]
     pub port: u16,
+    #[serde(default = "default_num_of_records")]
+    pub num_of_records: i64,
+    #[serde(default = "default_sample_size")]
+    pub sample_size: usize,
 }
 
 fn default_addr() -> String {
     "127.0.0.1".to_string()
 }
 
+fn default_num_of_records() -> i64 {
+    10000i64
+}
+
+fn default_sample_size() -> usize {
+    100
+}
+
 pub fn get_configuration() -> Result<AuditorSettings, config::ConfigError> {
     let base_path = std::env::current_dir().expect("Failed to determine the current directory");
     let configuration_directory = base_path.join("benches").join("configuration");
diff --git a/auditor/benches/configuration/bench.yaml b/auditor/benches/configuration/bench.yaml
index 0d9554bad..dc4412967 100644
--- a/auditor/benches/configuration/bench.yaml
+++ b/auditor/benches/configuration/bench.yaml
@@ -1,2 +1,4 @@
 addr: "localhost"
 port: 8000
+num_of_records: 10000
+sample_size: 100


Test patch: