mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 20:28:58 +00:00
fix(benchmark): use different data sets for benchmark and minifier test
This commit is contained in:
parent
56aaf31fb1
commit
2ba18e073c
6 changed files with 35 additions and 30 deletions
|
|
@ -1,18 +1,3 @@
|
|||
# Benchmark
|
||||
|
||||
See https://codspeed.io/web-infra-dev/oxc
|
||||
|
||||
# Files for benchmarks
|
||||
|
||||
* https://cdn.jsdelivr.net/npm/react@17.0.2/cjs/react.development.js
|
||||
* https://cdn.jsdelivr.net/npm/moment@2.29.1/moment.js
|
||||
* https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.js
|
||||
* https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js
|
||||
* https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.js
|
||||
* https://cdn.jsdelivr.net/npm/d3@6.3.1/dist/d3.js
|
||||
* https://cdn.jsdelivr.net/npm/terser@5.17.4/dist/bundle.min.js
|
||||
* https://cdn.jsdelivr.net/npm/three@0.124.0/build/three.js
|
||||
* https://cdn.jsdelivr.net/npm/victory@35.8.4/dist/victory.js
|
||||
* https://cdn.jsdelivr.net/npm/echarts@5.1.1/dist/echarts.js
|
||||
* https://cdn.jsdelivr.net/npm/antd@4.16.1/dist/antd.js
|
||||
* https://cdn.jsdelivr.net/npm/typescript@4.8.3/lib/typescript.js
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use oxc_tasks_common::TestFiles;
|
|||
|
||||
fn bench_minifier(criterion: &mut Criterion) {
|
||||
let mut group = criterion.benchmark_group("minifier");
|
||||
for file in TestFiles::new().files() {
|
||||
for file in TestFiles::minimal().files() {
|
||||
group.bench_with_input(
|
||||
BenchmarkId::from_parameter(&file.file_name),
|
||||
&file.source_text,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use oxc_tasks_common::TestFiles;
|
|||
|
||||
fn bench_parser(criterion: &mut Criterion) {
|
||||
let mut group = criterion.benchmark_group("parser");
|
||||
for file in TestFiles::new().files() {
|
||||
for file in TestFiles::minimal().files() {
|
||||
group.bench_with_input(
|
||||
BenchmarkId::from_parameter(&file.file_name),
|
||||
&file.source_text,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use oxc_tasks_common::TestFiles;
|
|||
|
||||
fn bench_semantic(criterion: &mut Criterion) {
|
||||
let mut group = criterion.benchmark_group("semantic");
|
||||
for file in TestFiles::new().files() {
|
||||
for file in TestFiles::minimal().files() {
|
||||
group.bench_with_input(
|
||||
BenchmarkId::from_parameter(&file.file_name),
|
||||
&file.source_text,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{fmt, str::FromStr};
|
||||
use std::{fmt, fs::read_to_string, str::FromStr};
|
||||
|
||||
use crate::project_root;
|
||||
use crate::request::agent;
|
||||
|
|
@ -14,21 +14,32 @@ impl Default for TestFiles {
|
|||
}
|
||||
|
||||
impl TestFiles {
|
||||
/// # Panics
|
||||
/// Fails to read file
|
||||
pub fn new() -> Self {
|
||||
let root = project_root();
|
||||
let files = std::fs::read_to_string(root.join("./tasks/libs.txt"))
|
||||
.unwrap()
|
||||
.lines()
|
||||
.map(|file| TestFile::new(file).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
let files = Self::get_files().into_iter().map(|file| TestFile::new(&file)).collect();
|
||||
Self { files }
|
||||
}
|
||||
|
||||
pub fn minimal() -> Self {
|
||||
let files = Self::get_files()
|
||||
.into_iter()
|
||||
.filter(|name| ["react", "vue", "antd", "typescript"].iter().any(|f| name.contains(f)))
|
||||
.map(|file| TestFile::new(&file))
|
||||
.collect();
|
||||
Self { files }
|
||||
}
|
||||
|
||||
pub fn files(&self) -> &Vec<TestFile> {
|
||||
&self.files
|
||||
}
|
||||
|
||||
fn get_files() -> Vec<String> {
|
||||
let root = project_root();
|
||||
read_to_string(root.join("./tasks/libs.txt"))
|
||||
.unwrap()
|
||||
.lines()
|
||||
.map(ToString::to_string)
|
||||
.collect::<Vec<_>>()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestFile {
|
||||
|
|
@ -39,9 +50,10 @@ pub struct TestFile {
|
|||
|
||||
impl TestFile {
|
||||
/// # Errors
|
||||
pub fn new(url: &str) -> Result<Self, String> {
|
||||
let (file_name, source_text) = Self::get_source_text(url)?;
|
||||
Ok(Self { url: url.to_string(), file_name, source_text })
|
||||
/// # Panics
|
||||
pub fn new(url: &str) -> Self {
|
||||
let (file_name, source_text) = Self::get_source_text(url).unwrap();
|
||||
Self { url: url.to_string(), file_name, source_text }
|
||||
}
|
||||
|
||||
/// # Errors
|
||||
|
|
|
|||
|
|
@ -1,4 +1,12 @@
|
|||
https://cdn.jsdelivr.net/npm/react@17.0.2/cjs/react.development.js
|
||||
https://cdn.jsdelivr.net/npm/moment@2.29.1/moment.js
|
||||
https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.js
|
||||
https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.js
|
||||
https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.js
|
||||
https://cdn.jsdelivr.net/npm/d3@6.3.1/dist/d3.js
|
||||
https://cdn.jsdelivr.net/npm/terser@5.17.4/dist/bundle.min.js
|
||||
https://cdn.jsdelivr.net/npm/three@0.124.0/build/three.js
|
||||
https://cdn.jsdelivr.net/npm/victory@35.8.4/dist/victory.js
|
||||
https://cdn.jsdelivr.net/npm/echarts@5.1.1/dist/echarts.js
|
||||
https://cdn.jsdelivr.net/npm/antd@4.16.1/dist/antd.js
|
||||
https://cdn.jsdelivr.net/npm/typescript@4.8.3/lib/typescript.js
|
||||
|
|
|
|||
Loading…
Reference in a new issue