Skip to content
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

bench: add sozo build bench for spawn and move #2419

Merged
merged 2 commits into from
Sep 16, 2024
Merged
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
22 changes: 22 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,25 @@ jobs:
alert-threshold: "130%"
comment-on-alert: true
alert-comment-cc-users: "@kariy,@glihm,@tarrencev"

bench-sozo:
runs-on: ubuntu-latest
container:
image: ghcr.io/dojoengine/dojo-dev:v1.0.0-alpha.11
steps:
- uses: actions/checkout@v3
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Running Sozo benchmarks
run: cargo bench --bench spawn-and-move-build -- --output-format bencher | sed 1d | tail -n 1 | tee output_sozo.txt
- uses: benchmark-action/github-action-benchmark@v1
with:
tool: "cargo"
output-file-path: output_sozo.txt
benchmark-data-dir-path: "."
# Access token to deploy GitHub Pages branch
github-token: ${{ secrets.GITHUB_TOKEN }}
# Push and deploy GitHub pages branch automatically
auto-push: true
alert-threshold: "130%"
comment-on-alert: true
alert-comment-cc-users: "@kariy,@glihm,@tarrencev"
4 changes: 4 additions & 0 deletions bin/sozo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ default = [ "controller", "walnut" ]

controller = [ "dep:account_sdk", "dep:reqwest", "dep:slot" ]
walnut = [ "dep:sozo-walnut", "sozo-ops/walnut" ]

[[bench]]
harness = false
name = "spawn-and-move-build"
46 changes: 46 additions & 0 deletions bin/sozo/benches/spawn-and-move-build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use std::time::Instant;

use dojo_lang::scarb_internal::compile_workspace;
use dojo_test_utils::compiler::CompilerTestSetup;
use scarb::compiler::Profile;
use scarb::core::TargetKind;
use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector};

// Criterion enforces at least 10 iterations, in the case of Sozo, we only need to compile the code
// once to have a baseline and compiling 10 times would have been too long for the CI.
// We also output the result in the `bencher` format which is the same as the one used in the
// `bench.yml` action.

fn build_spawn_and_move() {
let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/");

let config = setup.build_test_config("spawn-and-move", Profile::DEV);

let ws = scarb::ops::read_workspace(config.manifest_path(), &config)
.expect("Failed to read workspace");

let packages: Vec<_> = ws.members().collect();

let _compile_info = compile_workspace(
&config,
CompileOpts {
include_target_names: vec![],
include_target_kinds: vec![],
exclude_target_kinds: vec![TargetKind::TEST],
features: FeaturesOpts {
features: FeaturesSelector::AllFeatures,
no_default_features: false,
},
},
packages.iter().map(|p| p.id).collect(),
)
.expect("Failed to build spawn and move");
}

fn main() {
let start = Instant::now();
build_spawn_and_move();
let duration = start.elapsed();

println!("test build/Sozo.Cold ... bench: {} ns/iter (+/- 0)", duration.as_nanos());
kariy marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions bin/sozo/sozo_build_benchmark.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
26102
Loading