Skip to content

Commit d958153

Browse files
committed
feat: add CodSpeed to the project
1 parent da53c14 commit d958153

21 files changed

Lines changed: 139 additions & 21 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: codspeed-benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- "main" # or "master"
7+
pull_request:
8+
# `workflow_dispatch` allows CodSpeed to trigger backtest
9+
# performance analysis in order to generate initial data.
10+
workflow_dispatch:
11+
12+
env:
13+
TURBOPACK_BENCH_COUNTS: 50
14+
15+
jobs:
16+
benchmarks:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Setup rust toolchain, cache and cargo-codspeed binary
21+
uses: moonrepo/setup-rust@v1
22+
with:
23+
channel: stable
24+
cache-target: release
25+
bins: cargo-codspeed
26+
cache-base: main
27+
28+
- name: Build the benchmark target(s)
29+
run: |
30+
cargo codspeed build -p turbo-tasks-fs
31+
cargo codspeed build -p turbo-tasks-memory
32+
cargo codspeed build -p turbopack
33+
# cargo codspeed build -p turbopack-bench # disabled for now because it uses a custom benchmark iterator
34+
cargo codspeed build -p turbopack-cli
35+
cargo codspeed build -p turbopack-ecmascript
36+
37+
- name: Run the benchmarks
38+
uses: CodSpeedHQ/action@v2
39+
with:
40+
token: ${{ secrets.CODSPEED_TOKEN }}
41+
run: cargo codspeed run

Cargo.lock

Lines changed: 74 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ concurrent-queue = "2.1.0"
219219
console = "0.15.5"
220220
console-subscriber = "0.1.8"
221221
criterion = "0.4.0"
222+
codspeed-criterion-compat = "2.5.0"
222223
crossbeam-channel = "0.5.8"
223224
dashmap = "5.4.0"
224225
dialoguer = "0.10.3"

crates/turbo-tasks-fs/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ turbo-tasks-hash = { workspace = true }
5050
unicode-segmentation = { workspace = true }
5151

5252
[dev-dependencies]
53+
codspeed-criterion-compat = { workspace = true, features = ["async_tokio"] }
5354
criterion = { workspace = true, features = ["async_tokio"] }
5455
rstest = { workspace = true }
5556
sha2 = "0.10.2"

crates/turbo-tasks-fs/benches/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
time::{Duration, Instant},
66
};
77

8-
use criterion::{
8+
use codspeed_criterion_compat::{
99
criterion_group, criterion_main,
1010
measurement::{Measurement, WallTime},
1111
BenchmarkId, Criterion,

crates/turbo-tasks-memory/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ turbo-tasks-hash = { workspace = true }
3232
turbo-tasks-malloc = { workspace = true, default-features = false }
3333

3434
[dev-dependencies]
35+
codspeed-criterion-compat = { workspace = true, features = ["async_tokio"] }
3536
criterion = { workspace = true, features = ["async_tokio"] }
3637
indexmap = { workspace = true }
3738
lazy_static = { workspace = true }

crates/turbo-tasks-memory/benches/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(arbitrary_self_types)]
22

3-
use criterion::{criterion_group, criterion_main, Criterion};
3+
use codspeed_criterion_compat::{criterion_group, criterion_main, Criterion};
44

55
pub(crate) mod scope_stress;
66
pub(crate) mod stress;

crates/turbo-tasks-memory/benches/scope_stress.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use criterion::{BenchmarkId, Criterion};
2+
use codspeed_criterion_compat::{BenchmarkId, Criterion};
33
use turbo_tasks::{Completion, TryJoinIterExt, TurboTasks, Vc};
44
use turbo_tasks_memory::MemoryBackend;
55

@@ -19,7 +19,7 @@ pub fn scope_stress(c: &mut Criterion) {
1919
group.sample_size(20);
2020

2121
for size in [5, 10, 15, 20, 25, 30, 100, 200, 300] {
22-
group.throughput(criterion::Throughput::Elements(
22+
group.throughput(codspeed_criterion_compat::Throughput::Elements(
2323
/* tasks for fib from 0 to size - 1 = */
2424
(size as u64) * (size as u64) +
2525
/* root tasks = */

crates/turbo-tasks-memory/benches/stress.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use criterion::{BenchmarkId, Criterion};
2+
use codspeed_criterion_compat::{BenchmarkId, Criterion};
33
use turbo_tasks::{TryJoinIterExt, TurboTasks, Vc};
44
use turbo_tasks_memory::MemoryBackend;
55

@@ -19,7 +19,7 @@ pub fn fibonacci(c: &mut Criterion) {
1919
group.sample_size(20);
2020

2121
for size in [100, 200, 500, 1000, 1414] {
22-
group.throughput(criterion::Throughput::Elements(
22+
group.throughput(codspeed_criterion_compat::Throughput::Elements(
2323
/* tasks for fib from 0 to size - 1 = */
2424
size as u64 * (size as u64 + 1) / 2 +
2525
/* root task = */

crates/turbopack-bench/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ anyhow = { workspace = true, features = ["backtrace"] }
2121
chromiumoxide = { workspace = true, features = [
2222
"tokio-runtime",
2323
], default-features = false }
24+
codspeed-criterion-compat = { workspace = true, features = ["async_tokio"] }
2425
criterion = { workspace = true, features = ["async_tokio"] }
2526
futures = { workspace = true }
2627
once_cell = { workspace = true }

0 commit comments

Comments
 (0)