Skip to content

Commit

Permalink
chore: add more data to benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Nov 22, 2024
1 parent 6d9e761 commit 8ab444b
Showing 1 changed file with 45 additions and 36 deletions.
81 changes: 45 additions & 36 deletions benches/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,52 +8,61 @@ use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use rayon::prelude::*;

fn data() -> Vec<(PathBuf, &'static str)> {
let cwd = env::current_dir().unwrap().join("fixtures/enhanced_resolve");
let f = cwd.join("test/fixtures");
let cwd = env::current_dir().unwrap();
let f1 = cwd.join("fixtures/enhanced_resolve");
let f2 = f1.join("test/fixtures");
vec![
(cwd.clone(), "./"),
(cwd.clone(), "./lib/index"),
(cwd.clone(), "/absolute/path"),
// real packages
(cwd.clone(), "@napi-rs/cli"),
(cwd.clone(), "@napi-rs/wasm-runtime"),
(cwd.clone(), "ava"),
(cwd.clone(), "emnapi"),
(cwd.clone(), "typescript"),
// relative path
(f1.clone(), "./"),
(f1.clone(), "./lib/index"),
// absolute path
(f1.clone(), "/absolute/path"),
// query fragment
(f.clone(), "./main1.js#fragment?query"),
(f.clone(), "m1/a.js?query#fragment"),
(f2.clone(), "./main1.js#fragment?query"),
(f2.clone(), "m1/a.js?query#fragment"),
// browserField
(f.join("browser-module"), "./lib/replaced"),
(f.join("browser-module/lib"), "./replaced"),
(f2.join("browser-module"), "./lib/replaced"),
(f2.join("browser-module/lib"), "./replaced"),
// exportsField
(f.join("exports-field"), "exports-field"),
(f.join("exports-field"), "exports-field/dist/main.js"),
(f.join("exports-field"), "exports-field/dist/main.js?foo"),
(f.join("exports-field"), "exports-field/dist/main.js#foo"),
(f.join("exports-field"), "@exports-field/core"),
(f.join("imports-exports-wildcard"), "m/features/f.js"),
(f2.join("exports-field"), "exports-field"),
(f2.join("exports-field"), "exports-field/dist/main.js"),
(f2.join("exports-field"), "exports-field/dist/main.js?foo"),
(f2.join("exports-field"), "exports-field/dist/main.js#foo"),
(f2.join("exports-field"), "@exports-field/core"),
(f2.join("imports-exports-wildcard"), "m/features/f.js"),
// extensionAlias
(f.join("extension-alias"), "./index.js"),
(f.join("extension-alias"), "./dir2/index.mjs"),
(f2.join("extension-alias"), "./index.js"),
(f2.join("extension-alias"), "./dir2/index.mjs"),
// extensions
(f.join("extensions"), "./foo"),
(f.join("extensions"), "."),
(f.join("extensions"), "./dir"),
(f.join("extensions"), "module/"),
(f2.join("extensions"), "./foo"),
(f2.join("extensions"), "."),
(f2.join("extensions"), "./dir"),
(f2.join("extensions"), "module/"),
// importsField
(f.join("imports-field"), "#imports-field"),
(f.join("imports-exports-wildcard/node_modules/m/"), "#internal/i.js"),
(f2.join("imports-field"), "#imports-field"),
(f2.join("imports-exports-wildcard/node_modules/m/"), "#internal/i.js"),
// scoped
(f.join("scoped"), "@scope/pack1"),
(f.join("scoped"), "@scope/pack2/lib"),
(f2.join("scoped"), "@scope/pack1"),
(f2.join("scoped"), "@scope/pack2/lib"),
// dashed name
(f.clone(), "dash"),
(f.clone(), "dash-name"),
(f.join("node_modules/dash"), "dash"),
(f.join("node_modules/dash"), "dash-name"),
(f.join("node_modules/dash-name"), "dash"),
(f.join("node_modules/dash-name"), "dash-name"),
(f2.clone(), "dash"),
(f2.clone(), "dash-name"),
(f2.join("node_modules/dash"), "dash"),
(f2.join("node_modules/dash"), "dash-name"),
(f2.join("node_modules/dash-name"), "dash"),
(f2.join("node_modules/dash-name"), "dash-name"),
// alias
(cwd.clone(), "aaa"),
(cwd.clone(), "ggg"),
(cwd.clone(), "rrr"),
(cwd.clone(), "@"),
(cwd, "@@@"),
(f1.clone(), "aaa"),
(f1.clone(), "ggg"),
(f1.clone(), "rrr"),
(f1.clone(), "@"),
(f1, "@@@"),
]
}

Expand Down

0 comments on commit 8ab444b

Please # to comment.