1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use std::time::Instant; use crows_wasm::{run_wasm, Instance, Runtime}; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<(), anyhow::Error> { // let path = std::env::var("MODULE_PATH").expect("MODULE_PATH env var is not set"); // let content = std::fs::read(path).unwrap(); // // let mut receivers = Vec::new(); // let runtime = Runtime::new()?; // let instant = Instant::now(); // let mut futures = Vec::new(); // // // let (mut instance, receiver) = Instance::new(&content, &runtime.environment).await.unwrap(); // // receivers.push(receiver); // // let config = crows_wasm::fetch_config(&mut instance).await.unwrap(); // // println!("Config: {config:?}"); // for _ in 0..10 { // let (mut instance, receiver) = Instance::new(&content, &runtime.environment).await.unwrap(); // receivers.push(receiver); // let fut = async move { // run_wasm(&mut instance).await.unwrap(); // }; // futures.push(fut); // } // // tokio::spawn(async move { // let mut futures = Vec::new(); // for mut receiver in receivers { // let fut = async move { // while let Some(message) = receiver.recv().await { // println!("stdout: {}", String::from_utf8(message).unwrap()); // } // }; // futures.push(fut); // } // // futures::future::join_all(futures).await; // }); // // futures::future::join_all(futures).await; // // println!("elapsed: {}ms", instant.elapsed().as_millis()); // Ok(()) }