1- use {
2- crate :: tri,
3- criterion:: { BenchmarkGroup , Criterion , measurement:: WallTime } ,
4- doublets:: {
5- data:: LinkType ,
6- Doublets ,
7- mem:: { Alloc , FileMapped } ,
8- parts:: LinkPart ,
9- split:: { self , DataPart , IndexPart } , unit,
10- } ,
11- linkspsql:: { bench, benchmark_links, Benched , Client , connect, Exclusive , Fork , Transaction } ,
12- std:: { alloc:: Global , time:: { Duration , Instant } } ,
1+ //! # Doublets Create Links Benchmark
2+ //!
3+ //! This benchmark measures the performance of creating new links in Doublets.
4+ //!
5+ //! ## Implementation
6+ //!
7+ //! Doublets creates links by:
8+ //! - Allocating next available ID from internal counter
9+ //! - Writing (id, id, id) tuple directly to memory/file
10+ //! - Updating source and target indexes
11+ //! - Time complexity: O(log n) for index updates
12+
13+ use std:: {
14+ alloc:: Global ,
15+ time:: { Duration , Instant } ,
16+ } ;
17+
18+ use criterion:: { measurement:: WallTime , BenchmarkGroup , Criterion } ;
19+ use doublets:: {
20+ mem:: { Alloc , FileMapped } ,
21+ parts:: LinkPart ,
22+ split:: { self , DataPart , IndexPart } ,
23+ unit, Doublets ,
1324} ;
25+ use linkspsql:: { bench, benchmark_links, Benched , Fork } ;
1426
15- fn bench < T : LinkType , B : Benched + Doublets < T > > (
27+ use crate :: tri;
28+
29+ /// Runs the create benchmark on a Doublets backend.
30+ fn bench < B : Benched + Doublets < usize > > (
1631 group : & mut BenchmarkGroup < WallTime > ,
1732 id : & str ,
1833 mut benched : B ,
@@ -27,19 +42,10 @@ fn bench<T: LinkType, B: Benched + Doublets<T>>(
2742 } ) ;
2843}
2944
45+ /// Creates benchmark for Doublets backends on link creation.
3046pub fn create_links ( c : & mut Criterion ) {
3147 let mut group = c. benchmark_group ( "Create" ) ;
32- tri ! {
33- bench( & mut group, "PSQL_NonTransaction" , Exclusive :: <Client <usize >>:: setup( ( ) ) . unwrap( ) ) ;
34- }
35- tri ! {
36- let mut client = connect( ) . unwrap( ) ;
37- bench(
38- & mut group,
39- "PSQL_Transaction" ,
40- Exclusive :: <Transaction <' _, usize >>:: setup( & mut client) . unwrap( ) ,
41- ) ;
42- }
48+
4349 tri ! {
4450 bench(
4551 & mut group,
@@ -68,5 +74,6 @@ pub fn create_links(c: &mut Criterion) {
6874 split:: Store :: <usize , FileMapped <_>, FileMapped <_>>:: setup( ( "split_index.links" , "split_data.links" ) ) . unwrap( )
6975 )
7076 }
77+
7178 group. finish ( ) ;
7279}
0 commit comments