Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/parse_benchmark_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
# Parse benchmark results from game tests and convert to JSON format
# This script reads the benchmark results file and converts it to JSON format
# for use with benchmark-action/github-action-benchmark

set -e

BENCH_FILE="benchmark_results.json"
RESULTS_FILE="runs/gameTestServer/logs/benchmark_results.txt"

echo "Parsing benchmark results..."

# Initialize the JSON array
echo "[" > "$BENCH_FILE"

# Default values if file doesn't exist
if [ ! -f "$RESULTS_FILE" ]; then
echo "Benchmark results file not found at $RESULTS_FILE"
exit 1;
fi

FIRST=true
while IFS= read -r line; do
# Skip empty lines
if [ -z "$line" ]; then
continue
fi

# Parse the line: preset=<preset> size=<size> avgNetworkTickTime=<time> avgServerTickTime=<time>
# Using sed instead of grep -oP for macOS compatibility
preset=$(echo "$line" | sed -n 's/.*preset=\([^ ]*\).*/\1/p')
size=$(echo "$line" | sed -n 's/.*size=\([0-9]*\).*/\1/p')
networkTickTime=$(echo "$line" | sed -n 's/.*avgNetworkTickTime=\([0-9.]*\).*/\1/p')
serverTickTime=$(echo "$line" | sed -n 's/.*avgServerTickTime=\([0-9.]*\).*/\1/p')

if [ -n "$preset" ] && [ -n "$size" ] && [ -n "$networkTickTime" ]; then
# Output network tick time metric
if [ "$FIRST" = true ]; then
FIRST=false
else
echo "," >> "$BENCH_FILE"
fi

cat >> "$BENCH_FILE" << EOF
{
"name": "NETWORK LOAD: ${preset}_size_${size}",
"unit": "tick time (ms)",
"value": $networkTickTime
}
EOF
fi

# Output server tick time metric if available
if [ -n "$serverTickTime" ]; then
echo "," >> "$BENCH_FILE"
cat >> "$BENCH_FILE" << EOF
{
"name": "SERVER LOAD: ${preset}_size_${size}",
"unit": "tick time (ms)",
"value": $serverTickTime
}
EOF
fi
done < "$RESULTS_FILE"

# Close the JSON array
echo "" >> "$BENCH_FILE"
echo "]" >> "$BENCH_FILE"

# Display the results
echo "✓ Benchmark results parsed successfully:"
echo ""
cat "$BENCH_FILE"

64 changes: 64 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: "Performance"
on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
benchmark:
name: Benchmark
if: github.event.repository.fork != true && (startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/feature'))
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
submodules: true
- name: 'Setup Java'
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: 21
- name: 'Setup Gradle'
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: wrapper
cache-read-only: false
- name: 'Build'
run: ./gradlew build -x test --no-daemon
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 'Run performance benchmarks'
run: ./gradlew runGameTestServer
env:
PERFORMANCE_BENCHMARK_ENABLED: 'true'
continue-on-error: true
- name: 'Parse benchmark results'
run: bash .github/parse_benchmark_results.sh
- name: Determine benchmarks total results target directory name
run: echo "BENCHMARK_DATA_DIR_PATH=CyclopsMC/IntegratedCrafting/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}/benchmarks" >> $GITHUB_ENV
- name: 'Store benchmark result'
uses: benchmark-action/github-action-benchmark@v1
with:
name: Integrated Crafting Network Benchmark
tool: customSmallerIsBetter
output-file-path: benchmark_results.json
github-token: ${{ secrets.PAT }}
auto-push: true
alert-threshold: '250%'
comment-always: true
comment-on-alert: true
alert-comment-cc-users: '@rubensworks'
summary-always: true
gh-repository: github.com/CyclopsMC/cyclops-performance-results
gh-pages-branch: master
benchmark-data-dir-path: ${{ env.BENCHMARK_DATA_DIR_PATH }}
- name: Prepare comment on commit with link to performance results
run: echo -e "Performance benchmarks succeeded! 🚀\n\n\[[Results](https://CyclopsMC.github.io/cyclops-performance-results/CyclopsMC/IntegratedCrafting/${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}/benchmarks/)\]" > ./commit-comment-body.txt
- name: Comment on commit with link to performance results
uses: peter-evans/commit-comment@v4
with:
body-path: ./commit-comment-body.txt

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ logs/
secrets.properties
build_number.properties
changelog.txt

# Ignore generated performance benchmark results
benchmark_results.json
Loading
Loading