-
Notifications
You must be signed in to change notification settings - Fork 5
80 lines (71 loc) · 3.1 KB
/
Copy pathbenchmark.yml
File metadata and controls
80 lines (71 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Performance Benchmark
run-name: "⚡ Benchmark · ${{ github.event_name == 'workflow_dispatch' && 'Manual Run' || github.event.workflow_run.head_branch }}"
on:
workflow_run:
workflows: ["Unit Tests"]
types:
- completed
workflow_dispatch:
jobs:
benchmark:
name: Run Benchmarks
# 依赖 unit test 成功,或手动触发
if: |
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Zig
uses: mlugg/setup-zig@v2
with:
version: 0.16.0
- name: Display platform information
shell: bash
run: |
echo "================================"
echo "Platform Configuration"
echo "================================"
echo "OS: ${{ runner.os }}"
echo "Runner: ${{ matrix.os }}"
echo "Architecture: $(uname -m)"
if [ "$RUNNER_OS" == "Linux" ]; then
echo "Kernel: $(uname -r)"
echo "Distribution: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'=' -f2)"
echo "CPU: $(lscpu | grep 'Model name' | cut -d':' -f2 | xargs)"
echo "Total Memory: $(free -h | grep Mem | awk '{print $2}')"
elif [ "$RUNNER_OS" == "macOS" ]; then
echo "Kernel: $(uname -r)"
echo "CPU: $(sysctl -n machdep.cpu.brand_string)"
echo "Total Memory: $(sysctl -n hw.memsize | awk '{print $1/1024/1024/1024 " GB"}')"
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "Kernel: $(uname -r)"
echo "CPU: $(wmic cpu get name | sed -n 2p)"
echo "Total Memory: $(wmic computersystem get totalphysicalmemory | sed -n 2p | awk '{print $1/1024/1024/1024 " GB"}')"
fi
echo "================================"
echo ""
- name: Build benchmark binary
run: zig build -Doptimize=ReleaseFast
- name: Run benchmark
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
zig-out/bin/msgpack-bench.exe
else
zig-out/bin/msgpack-bench
fi
- name: Upload benchmark binary
uses: actions/upload-artifact@v4
with:
name: msgpack-bench-${{ runner.os }}-${{ github.sha }}
path: |
zig-out/bin/msgpack-bench
zig-out/bin/msgpack-bench.exe
retention-days: 7
if-no-files-found: ignore