Skip to content

feat: add a bench macro to canbench. #178

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

Merged
merged 9 commits into from
Jan 22, 2024
Merged

feat: add a bench macro to canbench. #178

merged 9 commits into from
Jan 22, 2024

Conversation

ielashi
Copy link
Contributor

@ielashi ielashi commented Jan 18, 2024

Rather than declaring benchmarks as queries on a canister, we now introduce a special #[bench] macro, which offers the following pros:

  1. It validates that the benchmark has no parameters.
  2. It validates that the benchmark returns a BenchResult
  3. It namespaces the benchmark with the prefix __canbench__. This is particularly useful if a benchmark is added to a production canister, then canbench can distinguish which queries are benchmarks.

1. `canbench` now by default stores results in `canbench_results.yml`.
   This is a reasonable default and helps simplify the tool's configuration.

2. Rename `benchmark-canisters` to `benchmarks`.

3. Move the benchmarking CI script into .github/workflows.

4. Cleanup dependencies and features in cargo
To more properly organize the benchmarking logic, the code is split into
two distinct crates:

1. `canbench-bin`: this is for the `canbench` binary that's used to run
   the benchmarks, and is agnostic to the language the canister is
   written in.

2. `canbench-rs`: a rust library for rust canister developers to use
   write benchmarks and add some profiling logic.

With this distinction, it'll be easier to support benchmarking canisters
written in other languages such Motoko or TypeScript.
Rather than declaring benchmarks as queries on a canister, we now
introduce a special `#[bench]` macro, which offers the following pros:

1. It validates that the benchmark has no parameters.
2. It validates that the benchmark returns a `BenchResult`
3. It namespaces the benchmark with the prefix `__canbench__`. This is
   particularly useful if a benchmark is added to a production canister,
   then `canbench` can distinguish which queries are benchmarks.
@ielashi ielashi requested a review from a team as a code owner January 18, 2024 15:43
Base automatically changed from ielashi/canbench_crates to main January 22, 2024 10:05
@ielashi ielashi enabled auto-merge (squash) January 22, 2024 10:21
@ielashi ielashi merged commit 7d0fd07 into main Jan 22, 2024
@ielashi ielashi deleted the ielashi/canbench_macro branch January 22, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants