From 4c453e9790d1cc5a2fd5c13fc2f63a145a3fd8da Mon Sep 17 00:00:00 2001 From: Motoyuki Kimura Date: Sat, 23 Mar 2024 23:41:41 +0900 Subject: [PATCH] readme: add description about benchmarks (#6425) --- .github/workflows/ci.yml | 3 +-- CONTRIBUTING.md | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4374d99ff63..e9738caebfc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,11 +210,10 @@ jobs: run: cargo hack test --each-feature working-directory: tests-build - # Check benchmarks. Run of benchmarks is done by bench.yml workflow. + # Check benchmarks. - name: Check benches run: cargo check --benches working-directory: benches - # bench.yml workflow runs benchmarks only on linux. if: startsWith(matrix.os, 'ubuntu') test-parking_lot: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 240b08be616..369a898fd98 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -347,6 +347,29 @@ example would explicitly use `Timeout::new`. For example: /// # } ``` +### Benchmarks + +You can run benchmarks locally for the changes you've made to the tokio codebase. +Tokio currently uses [Criterion](https://github.com/bheisler/criterion.rs) as its benchmarking tool. To run a benchmark +against the changes you have made, for example, you can run; + +```bash +cd benches + +# Run all benchmarks. +cargo bench + +# Run all tests in the `benches/fs.rs` file +cargo bench --bench fs + +# Run the `async_read_buf` benchmark in `benches/fs.rs` specifically. +cargo bench async_read_buf + +# After running benches, you can check the statistics under `tokio/target/criterion/` +``` + +You can also refer to Criterion docs for additional options and details. + ### Commits It is a recommended best practice to keep your changes as logically grouped as