@@ -82,20 +82,25 @@ fn cp_preserve_metadata(
8282
8383#[ divan:: bench( args = [ 16 ] ) ]
8484fn cp_large_file ( bencher : Bencher , size_mb : usize ) {
85- let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
86- let source = temp_dir. path ( ) . join ( "source.bin" ) ;
87- let dest = temp_dir. path ( ) . join ( "dest.bin" ) ;
88-
89- binary_data:: create_file ( & source, size_mb, b'x' ) ;
90-
91- let source_str = source. to_str ( ) . unwrap ( ) ;
92- let dest_str = dest. to_str ( ) . unwrap ( ) ;
93-
94- bencher. bench ( || {
95- fs_utils:: remove_path ( & dest) ;
96-
97- black_box ( run_util_function ( uumain, & [ source_str, dest_str] ) ) ;
98- } ) ;
85+ bencher
86+ . with_inputs ( || {
87+ let temp_dir = TempDir :: new ( ) . unwrap ( ) ;
88+ let source = temp_dir. path ( ) . join ( "source.bin" ) ;
89+ binary_data:: create_file ( & source, size_mb, b'x' ) ;
90+ ( temp_dir, source)
91+ } )
92+ . counter ( divan:: counter:: BytesCount :: new ( size_mb * 1024 * 1024 ) )
93+ . bench_values ( |( temp_dir, source) | {
94+ // Use unique destination name to avoid filesystem allocation variance
95+ let dest = temp_dir. path ( ) . join ( format ! (
96+ "dest_{}.bin" ,
97+ std:: ptr:: addr_of!( temp_dir) as usize
98+ ) ) ;
99+ let source_str = source. to_str ( ) . unwrap ( ) ;
100+ let dest_str = dest. to_str ( ) . unwrap ( ) ;
101+
102+ black_box ( run_util_function ( uumain, & [ source_str, dest_str] ) ) ;
103+ } ) ;
99104}
100105
101106fn main ( ) {
0 commit comments