#[cfg(feature = "constellation")] use constellation::*; use std::{ path::PathBuf, time::{Duration, SystemTime} }; use amadeus::dist::prelude::*; fn main() { if cfg!(miri) { return; } #[cfg(feature = "constellation")] init(Resources::default()); tokio::runtime::Builder::new() .threaded_scheduler() .enable_all() .build() .unwrap() .block_on(async { let thread_pool_time = { let thread_pool = ThreadPool::new(None, None).unwrap(); run(&thread_pool).await }; #[cfg(feature = "constellation")] let process_pool_time = { let process_pool = ProcessPool::new(None, None, None, Resources::default()).unwrap(); run(&process_pool).await }; #[cfg(not(feature = "constellation"))] let process_pool_time = "-"; println!("in {:?} {:?}", thread_pool_time, process_pool_time); }) } async fn run(pool: &P) -> Duration { let start = SystemTime::now(); #[derive(Data, Clone, PartialEq, PartialOrd, Debug)] struct GameDerived { a: String, b: String, c: String, d: String, e: u32, f: String, } let rows = Csv::<_, GameDerived>::new(PathBuf::from("amadeus-testing/csv/game.csv")) .await .unwrap(); assert_eq!( rows.dist_stream() .map(FnMut!(|row: Result<_, _>| row.unwrap())) .count(pool) .await, 100_000 ); #[derive(Data, Clone, PartialEq, PartialOrd, Debug)] struct GameDerived2 { a: String, b: String, c: String, d: String, e: u64, f: String, } let rows = Csv::<_, Value>::new(PathBuf::from("amadeus-testing/csv/game.csv")) .await .unwrap(); assert_eq!( rows.dist_stream() .map(FnMut!(|row: Result| -> Value { let value = row.unwrap(); // println!("{:?}", value); let _: GameDerived2 = value.clone().downcast().unwrap(); value })) .count(pool) .await, 100_000 ); start.elapsed().unwrap() }