Skip to content

macOS Version Build Benchmark #12

macOS Version Build Benchmark

macOS Version Build Benchmark #12

name: macOS Version Build Benchmark
on:
workflow_dispatch:
jobs:
benchmark:
name: Benchmark on ${{ matrix.os }} iteration #${{ matrix.iteration }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14, macos-15]
steps:
- name: Show Runner Info
run: |
echo "🖥 OS: ${{ matrix.os }}"
echo "🔁 Iteration: ${{ matrix.iteration }}"
echo "🧠 Architecture: $(uname -m)"
sw_vers
sysctl -n machdep.cpu.brand_string
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install CMake
run: brew install cmake
- name: Generate 6000 Source Files and main.cpp
run: |
mkdir -p src
echo "Generating 6000 source files..."
for i in $(seq 1 6000); do
echo "#include <iostream>" > src/file$i.cpp
echo "int func$i() {" >> src/file$i.cpp
echo " std::cout << \"Hello from file $i\" << std::endl;" >> src/file$i.cpp
echo " return $i;" >> src/file$i.cpp
echo "}" >> src/file$i.cpp
done
echo "Generating main.cpp..."
{
echo "#include <iostream>"
for i in $(seq 1 6000); do
echo "extern int func$i();"
done
echo "int main() {"
for i in $(seq 1 6000); do
echo " func$i();"
done
echo " return 0;"
echo "}"
} > main.cpp
- name: Show System Diagnostics (Before Build)
run: |
echo "CPU Info:"
sysctl -n machdep.cpu.brand_string
echo
echo "Memory Info:"
vm_stat
echo
echo "Disk Info:"
df -h /
- name: Configure CMake
run: |
mkdir -p build
cd build
cmake ..
- name: Build and Time Compilation
run: |
cd build
echo "Starting build at $(date)"
START=$(date +%s)
cmake --build . -j$(sysctl -n hw.ncpu)
END=$(date +%s)
echo "Build finished at $(date)"
BUILD_TIME=$((END - START))
echo "Total build time: ${BUILD_TIME} seconds"
echo "${{ matrix.os }} iteration #${{ matrix.iteration}} build time: ${BUILD_TIME}s" > ../build-time-${{ matrix.os }}-iteration-${{ matrix.iteration }}.log
- name: Upload Build Time Artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: build-time-${{ matrix.os }}-iteration-${{ matrix.iteration }}
path: build-time-${{ matrix.os }}-iteration-${{ matrix.iteration }}.log