Skip to content

Add benchmarking setup #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: release/0.0.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/base_benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches: main

jobs:
benchmark_base_branch:
name: Continuous Benchmarking
permissions:
checks: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- name: Track base branch benchmarks with Bencher
run: |
bencher run \
--project datex-core \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch main \
--testbed ubuntu-latest \
--threshold-measure latency \
--threshold-test t_test \
--threshold-max-sample-size 64 \
--threshold-upper-boundary 0.99 \
--thresholds-reset \
--err \
--adapter rust_criterion \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
cargo bench
29 changes: 29 additions & 0 deletions .github/workflows/pr_benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
pull_request:
types: [opened, reopened, edited, synchronize]

jobs:
benchmark_pr_branch:
name: Continuous Benchmarking PRs
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bencherdev/bencher@main
- name: Track PR Benchmarks with Bencher
run: |
bencher run \
--project datex-core \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch "$GITHUB_HEAD_REF" \
--start-point "$GITHUB_BASE_REF" \
--start-point-hash '${{ github.event.pull_request.base.sha }}' \
--start-point-clone-thresholds \
--start-point-reset \
--testbed ubuntu-latest \
--err \
--adapter rust_criterion \
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
cargo bench
7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ opt-level = 3
[profile.dev.package.num-bigint-dig]
opt-level = 3

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
criterion-macro = "0.4.0"


[features]
default = [
"nostd",
Expand All @@ -77,4 +82,4 @@ native_rand = ["rand"] # use native websocket
native_uuid = ["uuid"] # use native websocket
Copy link
Preview

Copilot AI Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment mismatch: 'use native websocket' should be updated to 'use native uuid'.

Suggested change
native_uuid = ["uuid"] # use native websocket
native_uuid = ["uuid"] # use native uuid

Copilot uses AI. Check for mistakes.

native_crypto = ["rsa"] # use native crypto
wasm_logger = ["console_log"]
std = [] # use std
std = [] # use std
17 changes: 17 additions & 0 deletions benches/runtime.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![feature(custom_test_frameworks)]
#![test_runner(criterion::runner)]
use criterion::{Criterion, black_box};
use criterion_macro::criterion;
use log::info;
use datex_core::runtime::Runtime;

// simple runtime initialization
fn runtime_init() {
let runtime = Runtime::default();
info!("Runtime version: {}", runtime.version);
}

#[criterion]
fn bench_simple(c: &mut Criterion) {
c.bench_function("runtime init", |b| b.iter(|| runtime_init()));
}
Loading