(args: I)
| 103 | } |
| 104 | |
| 105 | fn run_splashsurf_impl<I, T>(args: I) -> Result<(), anyhow::Error> |
| 106 | where |
| 107 | I: IntoIterator<Item = T>, |
| 108 | T: Into<std::ffi::OsString> + Clone, |
| 109 | { |
| 110 | let cmd_args = CommandlineArgs::parse_from(args); |
| 111 | |
| 112 | let verbosity = VerbosityLevel::from(cmd_args.verbosity); |
| 113 | let is_quiet = cmd_args.quiet; |
| 114 | |
| 115 | logging::initialize_logging(verbosity, is_quiet).context("Failed to initialize logging")?; |
| 116 | logging::log_program_info(); |
| 117 | |
| 118 | // Delegate to subcommands |
| 119 | let result = match &cmd_args.subcommand { |
| 120 | Subcommand::Reconstruct(cmd_args) => reconstruct::reconstruct_subcommand(cmd_args), |
| 121 | Subcommand::Convert(cmd_args) => convert::convert_subcommand(cmd_args), |
| 122 | }; |
| 123 | |
| 124 | // Write coarse_prof stats using log::info |
| 125 | info!("Timings:"); |
| 126 | splashsurf_lib::profiling::write_to_string() |
| 127 | .unwrap() |
| 128 | .split("\n") |
| 129 | .filter(|l| !l.is_empty()) |
| 130 | .for_each(|l| info!("{}", l)); |
| 131 | |
| 132 | // Print memory stats if available |
| 133 | if let Some(peak_allocation_bytes) = GLOBAL_ALLOCATOR.get_peak_allocated_memory() { |
| 134 | info!( |
| 135 | "Peak memory usage: {} bytes ({:.2}MB)", |
| 136 | peak_allocation_bytes, |
| 137 | peak_allocation_bytes as f64 * 1e-6 |
| 138 | ); |
| 139 | } |
| 140 | |
| 141 | info!( |
| 142 | "Finished at {}.", |
| 143 | chrono::Local::now().to_rfc3339_opts(chrono::SecondsFormat::Micros, false) |
| 144 | ); |
| 145 | |
| 146 | result |
| 147 | } |
| 148 | |
| 149 | #[derive(Copy, Clone, Debug)] |
| 150 | pub(crate) enum VerbosityLevel { |
no test coverage detected