-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(benchmark): add modules_10000 bench case (#9279)
* test(benchmark): add modules_10000 bench case * chore: lint * chore: update * fix: try * chore: lint
- Loading branch information
Showing
10,012 changed files
with
168,250 additions
and
10 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#![feature(trait_upcasting)] | ||
#![allow(unused_attributes)] | ||
#![allow(clippy::unwrap_used)] | ||
|
||
use std::{path::PathBuf, sync::Arc}; | ||
|
||
use criterion::criterion_group; | ||
use rspack::builder::Builder as _; | ||
use rspack_benchmark::Criterion; | ||
use rspack_core::{ | ||
Compiler, Experiments, Mode, ModuleOptions, ModuleRule, ModuleRuleEffect, ModuleRuleUse, | ||
ModuleRuleUseLoader, Resolve, RuleSetCondition, | ||
}; | ||
use rspack_fs::{MemoryFileSystem, NativeFileSystem}; | ||
use rspack_regex::RspackRegex; | ||
use serde_json::json; | ||
use tokio::runtime::Builder; | ||
|
||
async fn basic_compile(production: bool) { | ||
let dir = std::env::var("CARGO_MANIFEST_DIR") | ||
.map(PathBuf::from) | ||
.or( | ||
// This is a workaround for the issue where the CARGO_MANIFEST_DIR is not set in the test environment | ||
std::env::var("CODSPEED_CARGO_WORKSPACE_ROOT") | ||
.map(|workspace_root| PathBuf::from(workspace_root).join("tasks/benchmark")), | ||
) | ||
.unwrap() | ||
.join("benches/modules_10000"); | ||
|
||
let mut builder = Compiler::builder(); | ||
builder | ||
.context(dir.to_string_lossy().to_string()) | ||
.entry("main", "./index.jsx") | ||
.module(ModuleOptions::builder().rule(ModuleRule { | ||
test: Some(RuleSetCondition::Regexp( | ||
RspackRegex::new("\\.(j|t)s(x)?$").unwrap(), | ||
)), | ||
effect: ModuleRuleEffect { | ||
r#use: ModuleRuleUse::Array(vec![ModuleRuleUseLoader { | ||
loader: "builtin:swc-loader".to_string(), | ||
options: Some(json!({ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true, | ||
}, | ||
"transform": { | ||
"react": { | ||
"runtime": "automatic", | ||
}, | ||
}, | ||
"externalHelpers": true, | ||
}, | ||
"env": { | ||
"targets": "Chrome >= 48" | ||
} | ||
}).to_string()), | ||
}]), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
})) | ||
.cache(rspack_core::CacheOptions::Disabled) | ||
.resolve(Resolve { | ||
extensions: Some(vec!["...".to_string(), ".jsx".to_string()]), | ||
..Default::default() | ||
}) | ||
.experiments(Experiments::builder().css(true)) | ||
.input_filesystem(Arc::new(NativeFileSystem::new(false))) | ||
.output_filesystem(Arc::new(MemoryFileSystem::default())) | ||
.enable_loader_swc(); | ||
|
||
if production { | ||
builder.mode(Mode::Production); | ||
} else { | ||
builder.mode(Mode::Development); | ||
} | ||
|
||
let mut compiler = builder.build(); | ||
|
||
compiler.run().await.unwrap(); | ||
|
||
assert!(compiler | ||
.compilation | ||
.get_errors() | ||
.collect::<Vec<_>>() | ||
.is_empty()); | ||
} | ||
|
||
pub fn modules_10000_benchmark(c: &mut Criterion) { | ||
let rt = Builder::new_multi_thread().build().unwrap(); | ||
|
||
c.bench_function("10000_production", |b| { | ||
b.to_async(&rt).iter(|| basic_compile(true)); | ||
}); | ||
|
||
c.bench_function("10000_development", |b| { | ||
b.to_async(&rt).iter(|| basic_compile(false)); | ||
}); | ||
} | ||
|
||
criterion_group!(modules_10000, modules_10000_benchmark); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = [ | ||
{ | ||
rebuildChangeFile: "./src/f0.jsx", | ||
generateContent: function (originalContent, runTimes) { | ||
return ( | ||
`import "data:text/javascript,export default ${runTimes}"; | ||
` + originalContent | ||
); | ||
} | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>10000</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import React, { useEffect } from "react"; | ||
import ReactDom from "react-dom/client"; | ||
import App1 from "./src/f0"; | ||
|
||
ReactDom.createRoot(document.getElementById("root")).render( | ||
<React.StrictMode> | ||
<App1 /> | ||
</React.StrictMode> | ||
); | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "10000", | ||
"dependencies": { | ||
"react": "^19.0.0", | ||
"react-dom": "^19.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
const path = require("path"); | ||
const rspack = require("@rspack/core"); | ||
const ReactRefreshPlugin = require("@rspack/plugin-react-refresh"); | ||
|
||
const prod = process.env.NODE_ENV === "production"; | ||
/** @type {import("@rspack/cli").Configuration} */ | ||
module.exports = { | ||
resolve: { | ||
extensions: [".js", ".jsx"] | ||
}, | ||
entry: { main: "./index.jsx" }, | ||
plugins: [ | ||
new rspack.HtmlRspackPlugin({ | ||
template: path.resolve(__dirname, "./index.html") | ||
}), | ||
!prod && new ReactRefreshPlugin() | ||
].filter(Boolean), | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.(j|t)s$/, | ||
exclude: [/[\\/]node_modules[\\/]/], | ||
loader: "builtin:swc-loader", | ||
options: { | ||
sourceMap: true, | ||
jsc: { | ||
parser: { | ||
syntax: "typescript" | ||
}, | ||
externalHelpers: true | ||
}, | ||
env: { | ||
targets: "Chrome >= 48" | ||
} | ||
} | ||
}, | ||
{ | ||
test: /\.(j|t)sx$/, | ||
loader: "builtin:swc-loader", | ||
exclude: [/[\\/]node_modules[\\/]/], | ||
options: { | ||
sourceMap: true, | ||
jsc: { | ||
parser: { | ||
syntax: "typescript", | ||
tsx: true | ||
}, | ||
transform: { | ||
react: { | ||
runtime: "automatic", | ||
development: !prod, | ||
refresh: !prod | ||
} | ||
}, | ||
externalHelpers: true | ||
}, | ||
env: { | ||
targets: "Chrome >= 48" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
optimization: { | ||
splitChunks: { | ||
chunks: "all", | ||
cacheGroups: { | ||
d1: { | ||
test: /\/d1\// | ||
} | ||
} | ||
} | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
tasks/benchmark/benches/modules_10000/src/d0/d0/d0/d0/f0.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
|
||
import React, {useEffect} from 'react' | ||
import Icon from '@icon-park/react/es/all'; | ||
|
||
|
||
function Navbar({ show }) { | ||
useEffect(() => { | ||
console.log(Date.now()); | ||
}) | ||
return ( | ||
<div> | ||
<span> 19 </span> | ||
{Date.now()} | ||
</div> | ||
) | ||
} | ||
|
||
export default Navbar | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
tasks/benchmark/benches/modules_10000/src/d0/d0/d0/d0/f1.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import React from 'react' | ||
import Icon from '@icon-park/react/es/all'; | ||
|
||
|
||
function Navbar({ show }) { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default Navbar | ||
|
15 changes: 15 additions & 0 deletions
15
tasks/benchmark/benches/modules_10000/src/d0/d0/d0/d0/f2.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import React from 'react' | ||
import Icon from '@icon-park/react/es/all'; | ||
|
||
|
||
function Navbar({ show }) { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default Navbar | ||
|
15 changes: 15 additions & 0 deletions
15
tasks/benchmark/benches/modules_10000/src/d0/d0/d0/d0/f3.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
import React from 'react' | ||
import Icon from '@icon-park/react/es/all'; | ||
|
||
|
||
function Navbar({ show }) { | ||
return ( | ||
<div> | ||
|
||
</div> | ||
) | ||
} | ||
|
||
export default Navbar | ||
|
Oops, something went wrong.
aa7326b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Benchmark detail: Open
task failure
aa7326b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Ecosystem CI detail: Open