| @@ -15,8 +15,9 @@ pub(crate) fn test( |
| 15 | 15 | native: bool, |
| 16 | 16 | opts: &package::Options, |
| 17 | 17 | deps_warnings: bool, |
| 18 | + timings: &mut Timings, |
| 18 | 19 | ) -> ExitCode { |
| 19 | | − let compiled = match compile(path, true, opts, &mut Timings::default(), deps_warnings) { |
| 20 | + let compiled = match compile(path, true, opts, timings, deps_warnings) { |
| 20 | 21 | Ok(compiled) => compiled, |
| 21 | 22 | Err(code) => return code, |
| 22 | 23 | }; |
| @@ -49,7 +50,7 @@ pub(crate) fn test( |
| 49 | 50 | }) |
| 50 | 51 | .collect(); |
| 51 | 52 | let native_exe = if native { |
| 52 | | − match build_tests(&compiled, &tests) { |
| 53 | + match build_tests(&compiled, &tests, timings) { |
| 53 | 54 | Ok(exe) => Some(exe), |
| 54 | 55 | Err(code) => return code, |
| 55 | 56 | } |
| @@ -68,10 +69,11 @@ pub(crate) fn test( |
| 68 | 69 | }) |
| 69 | 70 | .collect(); |
| 70 | 71 | let mut program = program.clone(); |
| 71 | | − louise_core::opt::run_in(&mut program, &live); |
| 72 | + timings.time("optimise", || louise_core::opt::run_in(&mut program, &live)); |
| 72 | 73 | Some(program) |
| 73 | 74 | }; |
| 74 | 75 | let (mut passed, mut failed) = (0, 0); |
| 76 | + let started = std::time::Instant::now(); |
| 75 | 77 | for (index, (module, t)) in tests.iter().enumerate() { |
| 76 | 78 | { |
| 77 | 79 | let name = &t.name; |
| @@ -99,6 +101,7 @@ pub(crate) fn test( |
| 99 | 101 | } |
| 100 | 102 | } |
| 101 | 103 | } |
| 104 | + timings.add("run", started.elapsed()); |
| 102 | 105 | println!("\n{passed} passed, {failed} failed"); |
| 103 | 106 | if failed > 0 { |
| 104 | 107 | ExitCode::FAILURE |
| @@ -121,6 +124,7 @@ fn in_package(path: &str, name: &str) -> bool { |
| 121 | 124 | fn build_tests( |
| 122 | 125 | compiled: &Compiled, |
| 123 | 126 | tests: &[(&String, louise_core::Test)], |
| 127 | + timings: &mut Timings, |
| 124 | 128 | ) -> Result<PathBuf, ExitCode> { |
| 125 | 129 | let Compiled { |
| 126 | 130 | db, |
| @@ -137,16 +141,9 @@ fn build_tests( |
| 137 | 141 | .map(|(_, t)| louise_core::runnable(&analysis.hir, &analysis.typeck, program, t.def)) |
| 138 | 142 | .collect::<Result<Vec<_>, _>>() |
| 139 | 143 | .map_err(fail)?; |
| 140 | | − let mut timings = Timings::default(); |
| 141 | 144 | let units = louise_build::default_units(false); |
| 142 | | − let c = louise_codegen_c::generate_units( |
| 143 | | − program, |
| 144 | | − &entries, |
| 145 | | − Some(db.sources()), |
| 146 | | − units, |
| 147 | | − &mut timings, |
| 148 | | − ) |
| 149 | | − .map_err(|e| fail(e.to_string()))?; |
| 145 | + let c = louise_codegen_c::generate_units(program, &entries, Some(db.sources()), units, timings) |
| 146 | + .map_err(|e| fail(e.to_string()))?; |
| 150 | 147 | let opts = louise_build::CcOptions { |
| 151 | 148 | natives: loaded.natives(), |
| 152 | 149 | ..Default::default() |
| @@ -163,7 +160,7 @@ fn build_tests( |
| 163 | 160 | .to_owned(), |
| 164 | 161 | }; |
| 165 | 162 | let exe = build.join("test").join(format!("{name}-tests")); |
| 166 | | − louise_build::build_executable_timed(&c, &exe, &build, &opts, &mut timings) |
| 163 | + louise_build::build_executable_timed(&c, &exe, &build, &opts, timings) |
| 167 | 164 | .map_err(|e| fail(e.to_string()))?; |
| 168 | 165 | Ok(exe) |
| 169 | 166 | } |