Skip to content

Commit

Permalink
benchmark
Browse files Browse the repository at this point in the history
fix benchmark

use sh

fix path

bench

bench

get latest artifacts

fix artifact name

farm

complete

farm-linux

replace fnm with farm

bench

specify workflow

permission

permission

permission

permission

permission

bench

executable

run

shell script

permission

use rbenv in github

change min-runs

export env

install rbenv

remove rbenv install -L

add uninstall

fix min-runs

fix min-runs

3 runs

use home path

warmup

add ruby bin path

fix ./farm

change min-runs to 10

replace farm with frum

get latest release

remove id

change param type

embed params

rm overlappted params

echo url

add option

rename farm to frum

uninstall every time

rm version

force uninstall

prepare benchmark

remove comment

remove warmup

add frum_reason

command exists?

print help

print version

chmod

add warmup

make install -j

remove warmup

add warmup

20 runs

benchmark for initializing

install version before benchmark

fix subcommand
  • Loading branch information
TaKO8Ki committed Aug 23, 2021
1 parent 65b6fe3 commit b9d5dfd
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 0 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Benchmark

on:
push:
branches:
- benchmark

jobs:
build_linux_binary:
name: Build Linux binary
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build static binary
run: |
sudo chown -R 1000:1000 .
docker run --rm -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:stable \
cargo build --release
sudo chown -R $(whoami):$(whoami) .
- name: Compress binary using UPX
run: |
sudo apt-get install -y upx
upx target/x86_64-unknown-linux-musl/release/frum
- uses: actions/upload-artifact@v2
with:
name: frum-linux
path: target/x86_64-unknown-linux-musl/release/frum

benchmark_on_linux:
name: Benchmark (Linux)
needs: [build_linux_binary]
runs-on: ubuntu-latest
steps:
- uses: octokit/request-action@v2.x
id: get_benchmark_workflows
with:
route: GET /repos/:repository/actions/runs
repository: ${{ github.repository }}
branch: benchmark
status: completed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: octokit/request-action@v2.x
id: get_latest_release
with:
route: GET /repos/:repository/releases/latest
repository: ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Take the output
run: |
URL=$(echo '${{ steps.get_latest_release.outputs.data }}' | jq -r '.assets | map(select(.name | endswith("x86_64-unknown-linux-musl.tar.gz"))) | .[0].browser_download_url')
echo $URL
curl -L $URL -H 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' > /tmp/frum-latest.tar.gz
mkdir ~/.frum-latest
tar -zxvf /tmp/frum-latest.tar.gz -C ~/.frum-latest --strip-components=1
ls -lah ~/.frum-latest
- uses: actions/checkout@v2
- name: Install hyperfine
run: |
wget https://github.com/sharkdp/hyperfine/releases/download/v1.10.0/hyperfine_1.10.0_amd64.deb
sudo dpkg -i hyperfine_1.10.0_amd64.deb
- name: Install rbenv
run: |
git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
- uses: actions/download-artifact@v2
with:
name: frum-linux
path: target/release/
- name: Run benchmarks
run: ./benchmarks/run

- name: Read basic.md for the generated report
id: basic_result
uses: juliangruber/read-file-action@v1
with:
path: benchmarks/results/basic.md

- uses: octokit/request-action@v2.x
with:
route: POST /repos/:repository/commits/:commit_sha/comments
repository: ${{ github.repository }}
commit_sha: ${{ github.sha }}
body: |
|
${{ steps.basic_result.outputs.content }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions benchmarks/frum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

eval "$(~/.frum-latest/frum init)"
# ~/.frum-latest/frum install 2.6.5
# ~/.frum-latest/frum local 2.6.5
# ruby -v
6 changes: 6 additions & 0 deletions benchmarks/frum_reason
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

eval "$(frum init)"
# frum install 2.6.5
# frum local 2.6.5
# ruby -v
6 changes: 6 additions & 0 deletions benchmarks/rbenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

eval "$(rbenv init -)"
# rbenv install 2.6.5
# rbenv local 2.6.5
# ruby -v
54 changes: 54 additions & 0 deletions benchmarks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# #!/bin/bash

set -e

export frum_DIR

BASE_DIR="$(dirname "$(realpath "$0")")"
cd "$BASE_DIR" || exit 1

frum_DIR="$(mktemp -d)"
export PATH="$BASE_DIR/../target/release:$PATH"

mkdir results 2>/dev/null || :

if [ ! -f "$BASE_DIR/../target/release/frum" ]; then
echo "Can't access the release version of frum"
exit 1
fi

if ! command -v hyperfine >/dev/null 2>&1; then
echo "Can't access Hyperfine. Are you sure it is installed?"
echo " if not, visit https://github.com/sharkdp/hyperfine"
exit 1
fi

chmod +x ./frum
chmod +x ./frum_reason
chmod +x ./rbenv
chmod +x ~/.frum-latest/frum
chmod +x ../target/release/frum

export PATH="$HOME/.rbenv/bin:$PATH"
export PATH="$HOME/.rbenv/shims:$PATH"

# command exists?
~/.frum-latest/frum -V
frum -V
rbenv -v
frum install 2.6.5
rbenv install 2.6.5
frum global 2.6.5
rbenv global 2.6.5

hyperfine \
--warmup 2 \
--min-runs=20 \
--time-unit=millisecond \
--export-json="./results/basic.json" \
--export-markdown="./results/basic.md" \
--show-output \
--prepare 'rm -rf ~/.rbenv/versions/2.6.5 ~/.frum/versions/2.6.5' \
"./rbenv" \
"./frum" \
"./frum_reason"
2 changes: 2 additions & 0 deletions src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ fn build_package(
};
debug!("make install");
let make_install = Command::new("make")
.arg("-j")
.arg(&num_cpus::get().to_string())
.arg("install")
.current_dir(&current_dir)
.output()
Expand Down

1 comment on commit b9d5dfd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command Mean [ms] Min [ms] Max [ms] Relative
./rbenv 69.9 ± 3.9 62.8 79.5 3.64 ± 0.46
./frum 19.2 ± 2.2 16.5 33.4 1.00
./frum_reason 57.5 ± 5.2 49.0 67.8 2.99 ± 0.43

Please sign in to comment.