@@ -398,6 +398,18 @@ mod codspeed {
398398 pub fn set_macro_group ( & mut self , macro_group : impl Into < String > ) {
399399 self . macro_group = macro_group. into ( ) ;
400400 }
401+
402+ /// Ensures `current_file` is set, for CodSpeed URI generation.
403+ ///
404+ /// When set explicitly via `set_current_file`, it is kept as-is; otherwise it is
405+ /// derived from the caller location.
406+ #[ track_caller]
407+ pub ( crate ) fn ensure_current_file ( & mut self ) {
408+ if !self . current_file . is_empty ( ) {
409+ return ;
410+ }
411+ self . current_file = codspeed:: utils:: caller_file_path ( ) ;
412+ }
401413 }
402414}
403415
@@ -1201,7 +1213,9 @@ https://bheisler.github.io/criterion.rs/book/faq.html
12011213 /// ```
12021214 /// # Panics:
12031215 /// Panics if the group name is empty
1216+ #[ track_caller]
12041217 pub fn benchmark_group < S : Into < String > > ( & mut self , group_name : S ) -> BenchmarkGroup < ' _ , M > {
1218+ self . ensure_current_file ( ) ;
12051219 let group_name = group_name. into ( ) ;
12061220 assert ! ( !group_name. is_empty( ) , "Group name must not be empty." ) ;
12071221
@@ -1238,6 +1252,7 @@ where
12381252 /// criterion_group!(benches, bench);
12391253 /// criterion_main!(benches);
12401254 /// ```
1255+ #[ track_caller]
12411256 pub fn bench_function < F > ( & mut self , id : & str , f : F ) -> & mut Criterion < M >
12421257 where
12431258 F : FnMut ( & mut Bencher < ' _ , M > ) ,
@@ -1270,6 +1285,7 @@ where
12701285 /// criterion_group!(benches, bench);
12711286 /// criterion_main!(benches);
12721287 /// ```
1288+ #[ track_caller]
12731289 pub fn bench_with_input < F , I > ( & mut self , id : BenchmarkId , input : & I , f : F ) -> & mut Criterion < M >
12741290 where
12751291 F : FnMut ( & mut Bencher < ' _ , M > , & I ) ,
0 commit comments