Unverified Commit edd09733 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

chore(turbopack): Cleanup benchmark code (#79943)

### What?

Cleanup code for benchmarking

### Why?


https://github.com/vercel/next.js/pull/79796#pullrequestreview-2879675461

---------
Co-authored-by: 's avatarLuke Sandberg <lukesandberg@users.noreply.github.com>
parent 0084361f
...@@ -29,7 +29,7 @@ fn list_apps() -> (PathBuf, Vec<PathBuf>) { ...@@ -29,7 +29,7 @@ fn list_apps() -> (PathBuf, Vec<PathBuf>) {
let path = entry.path(); let path = entry.path();
if path.is_dir() { if path.is_dir() {
// Exclude node_modules // Exclude node_modules
if path.file_name().unwrap().to_string_lossy() == "node_modules" { if path.file_name().unwrap_or_default() == "node_modules" {
continue; continue;
} }
...@@ -68,7 +68,6 @@ fn bench_small_apps(c: &mut Criterion) { ...@@ -68,7 +68,6 @@ fn bench_small_apps(c: &mut Criterion) {
let app_name = app.file_name().unwrap().to_string_lossy().to_string(); let app_name = app.file_name().unwrap().to_string_lossy().to_string();
rt.block_on(async move { rt.block_on(async move {
//
turbopack_cli::build::build(&BuildArguments { turbopack_cli::build::build(&BuildArguments {
common: CommonArguments { common: CommonArguments {
entries: Some(vec![format!("{app_name}/index.tsx")]), entries: Some(vec![format!("{app_name}/index.tsx")]),
......
...@@ -199,7 +199,7 @@ async fn build_internal( ...@@ -199,7 +199,7 @@ async fn build_internal(
target: Target, target: Target,
) -> Result<Vc<()>> { ) -> Result<Vc<()>> {
let output_fs = output_fs(project_dir.clone()); let output_fs = output_fs(project_dir.clone());
let project_fs = project_fs(root_dir.clone()); let project_fs = project_fs(root_dir.clone(), /* watch= */ false);
let project_relative = project_dir.strip_prefix(&*root_dir).unwrap(); let project_relative = project_dir.strip_prefix(&*root_dir).unwrap();
let project_relative: RcStr = project_relative let project_relative: RcStr = project_relative
.strip_prefix(MAIN_SEPARATOR) .strip_prefix(MAIN_SEPARATOR)
......
...@@ -264,7 +264,7 @@ async fn source( ...@@ -264,7 +264,7 @@ async fn source(
.into(); .into();
let output_fs = output_fs(project_dir); let output_fs = output_fs(project_dir);
let fs: Vc<Box<dyn FileSystem>> = project_fs(root_dir); let fs: Vc<Box<dyn FileSystem>> = project_fs(root_dir, /* watch= */ true);
let root_path = fs.root().to_resolved().await?; let root_path = fs.root().to_resolved().await?;
let project_path = root_path.join(project_relative).to_resolved().await?; let project_path = root_path.join(project_relative).to_resolved().await?;
......
...@@ -60,9 +60,9 @@ pub fn normalize_entries(entries: &Option<Vec<String>>) -> Vec<RcStr> { ...@@ -60,9 +60,9 @@ pub fn normalize_entries(entries: &Option<Vec<String>>) -> Vec<RcStr> {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn project_fs(project_dir: RcStr) -> Result<Vc<Box<dyn FileSystem>>> { pub async fn project_fs(project_dir: RcStr, watch: bool) -> Result<Vc<Box<dyn FileSystem>>> {
let disk_fs = DiskFileSystem::new("project".into(), project_dir, vec![]); let disk_fs = DiskFileSystem::new("project".into(), project_dir, vec![]);
if cfg!(not(codspeed)) { if watch {
disk_fs.await?.start_watching(None).await?; disk_fs.await?.start_watching(None).await?;
} }
Ok(Vc::upcast(disk_fs)) Ok(Vc::upcast(disk_fs))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment