Skip to content

Commit

Permalink
Use Bevy hash in Bencher (#3)
Browse files Browse the repository at this point in the history
* feat: depend on all of bevy

This will hurt compile times, but will allow us to get the commit hash and test other non-ECS parts of Bevy in the future.

* feat: find hash and specify in ci

* fix: install alsa and udev

* feat: log source and hash
  • Loading branch information
BD103 authored Jun 11, 2024
1 parent 28c506d commit fef3886
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
36 changes: 29 additions & 7 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,49 @@ jobs:
- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Cache build files
uses: Leafwing-Studios/cargo-cache@v1

- name: Install Bencher
uses: bencherdev/bencher@main

- name: Install Linux dependencies
run: |
sudo apt-get update
# Installs Alsa and udev.
sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
- name: Cache build files
uses: Leafwing-Studios/cargo-cache@v1

# Run benchmarks, piping output to both `results.txt` and stdout.
- name: Run benchmarks
run: cargo bench -- 2>&1 | tee results.txt

- name: Find Bevy commit hash
id: bevy-hash
run: |
# Find the source property of Bevy, which returns something like:
# "git+https://github.com/bevyengine/bevy.git#d659a1f7d506c5c6eba9dfe2a6e878a8c72ecef6"
SOURCE=$(cargo metadata --format-version 1 | jq '.packages[] | select(.name == "bevy") | .source')
echo Bevy source is $SOURCE.
# Regex for a 40-character hexadecimal hash.
REGEX="[a-f0-9]{40}"
# Capture the hash from the source identifier.
HASH=$(echo $SOURCE | grep --extended-regexp --only-matching $REGEX)
echo Found hash is $HASH.
echo hash=$HASH >> $GITHUB_OUTPUT
- name: Upload benchmarks
env:
BENCHER_PROJECT: bevy
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
BENCHER_TESTBED: github-actions
# --no-hash: Do not use the Git hash, because we care about the Bevy commit and not our
# own.
# --file: Upload saved Criterion output instead of running a command.
run: |
bencher run \
--adapter rust_criterion \
--no-hash \
--hash ${{ steps.bevy-hash.outputs.hash }}
--err \
--file results.txt
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ criterion = "0.5.1"
rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }

# Bevy, on the latest commit.
bevy_ecs = { git = "https://github.com/bevyengine/bevy.git" }
bevy = { git = "https://github.com/bevyengine/bevy.git" }

[[bench]]
name = "main"
Expand Down
2 changes: 1 addition & 1 deletion benches/ecs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod types;

use self::types::*;
use bevy_ecs::prelude::*;
use bevy::ecs::prelude::*;
use criterion::{criterion_group, BatchSize, Criterion};
use rand::prelude::*;
use std::{hint::black_box, iter::repeat};
Expand Down
2 changes: 1 addition & 1 deletion benches/ecs/types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy_ecs::prelude::*;
use bevy::ecs::prelude::*;

/// A 32-bit wide component.
///
Expand Down

0 comments on commit fef3886

Please sign in to comment.