graph_api_benches/
lib.rs

1pub mod construction;
2pub mod edge;
3pub mod generators;
4pub mod index;
5pub mod mutation;
6pub mod query;
7pub mod scale;
8pub mod traversal;
9pub mod vertex;
10
11use criterion::BenchmarkGroup;
12use graph_api_test::{Edge, Vertex};
13use std::time::Duration;
14
15/// Configures the default settings for benchmark groups
16pub fn configure_group(group: &mut BenchmarkGroup<criterion::measurement::WallTime>) {
17    group.measurement_time(Duration::from_secs(3));
18    group.sample_size(50);
19    group.warm_up_time(Duration::from_millis(500));
20}
21
22#[macro_export]
23macro_rules! bench_suite {
24    ($criterion:expr, $setup:expr) => {
25        let criterion: &mut criterion::Criterion = $criterion;
26
27        // Run vertex operation benchmarks
28        let mut vertex_group = criterion.benchmark_group("vertex_operations");
29        $crate::configure_group(&mut vertex_group);
30        $crate::vertex::run_benchmarks(&mut vertex_group, $setup);
31        vertex_group.finish();
32
33        // Run edge operation benchmarks
34        let mut edge_group = criterion.benchmark_group("edge_operations");
35        $crate::configure_group(&mut edge_group);
36        $crate::edge::run_benchmarks(&mut edge_group, $setup);
37        edge_group.finish();
38
39        // Run traversal operation benchmarks
40        let mut traversal_group = criterion.benchmark_group("traversal_operations");
41        $crate::configure_group(&mut traversal_group);
42        $crate::traversal::run_benchmarks(&mut traversal_group, $setup);
43        traversal_group.finish();
44
45        // Run query operation benchmarks
46        let mut query_group = criterion.benchmark_group("query_operations");
47        $crate::configure_group(&mut query_group);
48        $crate::query::run_benchmarks(&mut query_group, $setup);
49        query_group.finish();
50
51        // Run mutation operation benchmarks
52        let mut mutation_group = criterion.benchmark_group("mutation_operations");
53        $crate::configure_group(&mut mutation_group);
54        $crate::mutation::run_benchmarks(&mut mutation_group, $setup);
55        mutation_group.finish();
56
57        // Run construction benchmarks
58        let mut construction_group = criterion.benchmark_group("construction");
59        $crate::configure_group(&mut construction_group);
60        $crate::construction::run_benchmarks(&mut construction_group, $setup);
61        construction_group.finish();
62
63        // Run vertex label index benchmarks
64        let mut vertex_label_group = criterion.benchmark_group("vertex_label_index");
65        $crate::configure_group(&mut vertex_label_group);
66        $crate::index::vertex_label::bench_label_lookup(&mut vertex_label_group, $setup.clone());
67        $crate::index::vertex_label::bench_label_insertion(&mut vertex_label_group, $setup.clone());
68        $crate::index::vertex_label::bench_label_removal(&mut vertex_label_group, $setup.clone());
69        vertex_label_group.finish();
70
71        // Run vertex hash index benchmarks
72        let mut vertex_hash_group = criterion.benchmark_group("vertex_hash_index");
73        $crate::configure_group(&mut vertex_hash_group);
74        $crate::index::vertex_hash::bench_lookup(&mut vertex_hash_group, $setup.clone());
75        $crate::index::vertex_hash::bench_insertion(&mut vertex_hash_group, $setup.clone());
76        $crate::index::vertex_hash::bench_removal(&mut vertex_hash_group, $setup.clone());
77        vertex_hash_group.finish();
78
79        // Run vertex full-text index benchmarks
80        let mut vertex_full_text_group = criterion.benchmark_group("vertex_full_text_index");
81        $crate::configure_group(&mut vertex_full_text_group);
82        $crate::index::vertex_full_text::bench_lookup(&mut vertex_full_text_group, $setup.clone());
83        $crate::index::vertex_full_text::bench_insertion(
84            &mut vertex_full_text_group,
85            $setup.clone(),
86        );
87        $crate::index::vertex_full_text::bench_removal(&mut vertex_full_text_group, $setup.clone());
88        vertex_full_text_group.finish();
89
90        // Run vertex range index benchmarks
91        let mut vertex_range_group = criterion.benchmark_group("vertex_range_index");
92        $crate::configure_group(&mut vertex_range_group);
93        $crate::index::vertex_range::bench_lookup(&mut vertex_range_group, $setup.clone());
94        $crate::index::vertex_range::bench_insertion(&mut vertex_range_group, $setup.clone());
95        $crate::index::vertex_range::bench_removal(&mut vertex_range_group, $setup.clone());
96        vertex_range_group.finish();
97
98        // Run edge label index benchmarks
99        let mut edge_label_group = criterion.benchmark_group("edge_label_index");
100        $crate::configure_group(&mut edge_label_group);
101        $crate::index::edge_label::bench_lookup(&mut edge_label_group, $setup.clone());
102        $crate::index::edge_label::bench_insertion(&mut edge_label_group, $setup.clone());
103        $crate::index::edge_label::bench_removal(&mut edge_label_group, $setup.clone());
104        edge_label_group.finish();
105
106        // Run no-index benchmarks (baseline performance)
107        let mut no_index_group = criterion.benchmark_group("no_index");
108        $crate::configure_group(&mut no_index_group);
109        $crate::index::no_index::bench_vertex_insertion(&mut no_index_group, $setup.clone());
110        $crate::index::no_index::bench_edge_insertion(&mut no_index_group, $setup.clone());
111        $crate::index::no_index::bench_vertex_scan(&mut no_index_group, $setup.clone());
112        $crate::index::no_index::bench_vertex_removal(&mut no_index_group, $setup.clone());
113        $crate::index::no_index::bench_edge_removal(&mut no_index_group, $setup.clone());
114        no_index_group.finish();
115
116        // Run scaling benchmarks
117        let mut scale_group = criterion.benchmark_group("scaling");
118        $crate::configure_group(&mut scale_group);
119        $crate::scale::run_benchmarks(&mut scale_group, $setup);
120        scale_group.finish();
121    };
122}