diff --git a/.github/workflows/bench-deploy.yml b/.github/workflows/bench-deploy.yml index 5c4721b2..0d87d70f 100644 --- a/.github/workflows/bench-deploy.yml +++ b/.github/workflows/bench-deploy.yml @@ -30,7 +30,7 @@ jobs: run: cargo install cargo-criterion - name: Copy old benchmarks locally for comparison run: | - mkdir -p target gh-pages/benchmarks/criterion + mkdir -p target gh-pages/benchmarks/criterion history cp -r gh-pages/benchmarks/criterion target - name: Set env vars run: | @@ -49,22 +49,22 @@ jobs: run: | echo $LABELS > labels.md tar -cvzf fibonacci-${{ env.SHORT_SHA }}.tar.gz Cargo.lock fibonacci-${{ env.SHORT_SHA }}.json labels.md - working-directory: ${{ github.workspace }} + # Outputs plots to `./history` + - name: Generate historical performance plot + run: | + cargo run + - name: Copy benchmark json to history + run: cp *.png fibonacci-${{ env.SHORT_SHA }}.tar.gz history/ - name: Deploy latest benchmark report uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./target/criterion destination_dir: benchmarks/criterion - # Outputs plots to `./history` - - name: Generate historical performance plot - run: cargo run - - name: Copy benchmark json to history - run: cp fibonacci-${{ env.SHORT_SHA }}.tar.gz history/ - name: Deploy benchmark history uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: history/ + publish_dir: history destination_dir: benchmarks/history keep_files: true \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 5b5ac633..c4fd1c77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use crate::plot::{generate_plots, prepare_plots}; // TODO: Switch to camino fn get_paths() -> std::io::Result> { - let entries = std::fs::read_dir("./benches")? + let entries = std::fs::read_dir(".")? .flatten() .filter_map(|e| { let ext = e.path(); diff --git a/src/plot.rs b/src/plot.rs index dd511e5a..ce8dbf50 100644 --- a/src/plot.rs +++ b/src/plot.rs @@ -8,7 +8,7 @@ use crate::data::BenchData; pub fn generate_plots(data: &Plots) -> Result<(), Box> { for plot in data.iter() { - let out_file_name = format!("history/{}.png", plot.0); + let out_file_name = format!("./{}.png", plot.0); let root = BitMapBackend::new(&out_file_name, (1024, 768)).into_drawing_area(); root.fill(&WHITE)?; @@ -64,9 +64,7 @@ pub fn generate_plots(data: &Plots) -> Result<(), Box> { } // To avoid the IO failure being ignored silently, we manually call the present function - root.present().expect( - "Unable to write result to file, please make sure 'history' dir exists under current dir", - ); + root.present().expect("Unable to write result to file"); println!("Result has been saved to {}", out_file_name); }