@@ -4,7 +4,7 @@ use std::{
44 fs,
55 path:: { Path , PathBuf } ,
66} ;
7- use tiger_lib:: { Everything , ModFile } ;
7+ use tiger_lib:: { Everything , Fileset } ;
88
99static CONFIG_PATH : & str = "../benches/ck3.toml" ;
1010
@@ -26,16 +26,16 @@ fn workspace_path(s: &str) -> PathBuf {
2626 let p = PathBuf :: from ( s) ;
2727 if p. is_relative ( ) {
2828 PathBuf :: from ( ".." ) . join ( p)
29- }
30- else {
29+ } else {
3130 p
3231 }
3332}
3433
3534fn bench_multiple ( c : & mut Criterion ) {
3635 let content = fs:: read_to_string ( CONFIG_PATH ) . unwrap ( ) ;
3736 let config: Config = toml:: from_str ( & content) . unwrap ( ) ;
38- let mut modfile_paths = config. modfile_paths . iter ( ) . map ( |p| workspace_path ( p) ) . collect :: < Vec < _ > > ( ) ;
37+ let mut modfile_paths =
38+ config. modfile_paths . iter ( ) . map ( |p| workspace_path ( p) ) . collect :: < Vec < _ > > ( ) ;
3939
4040 if let Some ( modfile_dir) = config. modfile_dir {
4141 let modfile_dir = workspace_path ( & modfile_dir) ;
@@ -46,35 +46,26 @@ fn bench_multiple(c: &mut Criterion) {
4646 modfile_paths. extend ( iter) ;
4747 }
4848
49+ let vanilla_dir = PathBuf :: from ( config. vanilla_dir ) ;
50+
4951 let mut group = c. benchmark_group ( "benchmark" ) ;
5052 group. sample_size ( config. sample_size . unwrap_or ( 10 ) ) ;
5153 for ( index, modfile_path) in modfile_paths. iter ( ) . enumerate ( ) {
52- let modfile = ModFile :: read ( modfile_path) . unwrap ( ) ;
5354 group. bench_with_input (
54- BenchmarkId :: new (
55- "mods" ,
56- format ! ( "{}. {}" , index + 1 , modfile. display_name( ) . unwrap_or_default( ) ) ,
57- ) ,
58- & modfile,
59- |b, modfile_ref| {
60- b. iter ( || bench_mod ( & config. vanilla_dir , modfile_ref) ) ;
55+ BenchmarkId :: new ( "mods" , format ! ( "{}. {}" , index + 1 , modfile_path. display( ) ) ) ,
56+ modfile_path,
57+ |b, modfile_path| {
58+ b. iter ( || bench_mod ( & vanilla_dir, modfile_path. clone ( ) ) ) ;
6159 } ,
6260 ) ;
6361 }
6462
6563 group. finish ( ) ;
6664}
6765
68- fn bench_mod ( vanilla_dir : & str , modfile : & ModFile ) {
69- let mut everything = Everything :: new (
70- None ,
71- Some ( Path :: new ( vanilla_dir) ) ,
72- None ,
73- None ,
74- & modfile. modpath ( ) ,
75- modfile. replace_paths ( ) ,
76- )
77- . unwrap ( ) ;
66+ fn bench_mod ( vanilla_dir : & Path , modfile_path : PathBuf ) {
67+ let fileset = Fileset :: builder ( Some ( vanilla_dir) ) . with_modfile ( modfile_path) . unwrap ( ) ;
68+ let mut everything = Everything :: new ( fileset, None , None , None ) . unwrap ( ) ;
7869 everything. load_all ( ) ;
7970 everything. validate_all ( ) ;
8071 everything. check_rivers ( ) ;
0 commit comments