authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-14 18:14:26-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-09-14 18:14:26-07:00
log27edf60651496408a92a37c7b9766881ed54758d
tree5476009ebf530c000e4d6a6571e76448b858d8e0
parentad4991f42895868d988668749d839ced1914f276

CI: measure perf difference of compiling hello world

and post comment on the PR

3 files changed, 60 insertions(+), 2 deletions(-)

.github/workflows/ci.yaml+12
...@@ -17,3 +17,15 @@ jobs:...@@ -17,3 +17,15 @@ jobs:
17 uses: actions/checkout@v317 uses: actions/checkout@v3
18 - name: Build and Test18 - name: Build and Test
19 run: sh ci/aarch64-linux-release.sh19 run: sh ci/aarch64-linux-release.sh
20 - name: Post Comment
21 uses: actions/github-script@v6
22 with:
23 script: |
24 const fs = require('fs');
25 const body = fs.readFileSync('perf.txt', 'utf8');
26 github.rest.issues.createComment({
27 issue_number: context.issue.number,
28 owner: context.repo.owner,
29 repo: context.repo.repo,
30 body: body,
31 });
ci/aarch64-linux-release.sh+5-2
...@@ -81,8 +81,6 @@ rm -rf ../build-new...@@ -81,8 +81,6 @@ rm -rf ../build-new
81mkdir ../build-new81mkdir ../build-new
82cd ../build-new82cd ../build-new
8383
84export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
85export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
86export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"84export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
87export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"85export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
8886
...@@ -108,3 +106,8 @@ stage3/bin/zig build -p stage4 \...@@ -108,3 +106,8 @@ stage3/bin/zig build -p stage4 \
108 --search-prefix "$PREFIX" \106 --search-prefix "$PREFIX" \
109 --zig-lib-dir "$(pwd)/../lib"107 --zig-lib-dir "$(pwd)/../lib"
110stage4/bin/zig test ../test/behavior.zig -I../test108stage4/bin/zig test ../test/behavior.zig -I../test
109
110# After all correctness checking, compare performance against the merge-base.
111cd ..
112sh ci/measure-perf-delta.sh "$ZIG" "$TARGET" "$MCPU" "$PREFIX" || \
113 echo "Error occurred measuring the performance delta of this pull request." > perf.txt
ci/measure-perf-delta.sh created+43
...@@ -0,0 +1,43 @@
1#!/bin/sh
2
3set -x
4set -e
5
6if [ -z "$GITHUB_BASE_REF" ]; then
7 exit 0
8fi
9
10ZIG="$1"
11TARGET="$2"
12MPCU="$3"
13PREFIX="$4"
14
15git checkout "$GITHUB_BASE_REF"
16
17rm -rf ../build-base
18mkdir ../build-base
19cd ../build-base
20
21export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
22export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
23
24cmake .. \
25 -DCMAKE_PREFIX_PATH="$PREFIX" \
26 -DCMAKE_BUILD_TYPE=Release \
27 -DZIG_TARGET_TRIPLE="$TARGET" \
28 -DZIG_TARGET_MCPU="$MCPU" \
29 -DZIG_STATIC=ON \
30 -DZIG_NO_LIB=ON \
31 -GNinja
32
33unset CC
34unset CXX
35
36ninja install
37
38cd ..
39
40poop \
41 "build-base/stage3/bin/zig build-exe test/standalone/hello_world/hello.zig" \
42 "build-head/stage3/bin/zig build-exe test/standalone/hello_world/hello.zig" \
43 > perf.txt