MasatoDev / boostest

14 stars 0 forks source link

Asynchronous and parallel processing of tasks that analyze AST and output code #6

Open MasatoDev opened 2 months ago

MasatoDev commented 2 months ago

Currently, we are not able to process multiple threads without using tools like tokio.

https://github.com/MasatoDev/boostest/blob/main/crates/boostest/src/lib.rs#L244

    for (path_buf, file) in contents {
        let path = path_buf.as_path();

        println!(
            "target file: {}",
            format!("{}", path.to_string_lossy()).green()
        );

        let mut mock_loader = MockLoader::new(setting.name.clone());
        let allocator = oxc::allocator::Allocator::default();
        let parser = Parser::new(&allocator, &file, source_type);
        let mut program = parser.parse().program;

        // The following function is the task of ast analysis and code generation
        boostest_utils::load_mock(&mut mock_loader, &mut program, path, &setting.tsconfig);

        handle_main_task(&mut mock_loader, path, &out_file_name).expect("error main task");

        pb.inc(1);
    }
MasatoDev commented 1 month ago

https://github.com/MasatoDev/boostest/tree/chore/benchmark

hyperfine --warmup 3 'pnpm --filter test boostest'

Benchmark 1: pnpm --filter test boostest
  Time (mean ± σ):     780.1 ms ±  85.9 ms    [User: 667.3 ms, System: 137.7 ms]
  Range (min … max):   700.6 ms … 966.8 ms    10 runs