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
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
IndentWidth: 4
Language: Cpp
Standard: Latest
UseCRLF: false
UseTab: Never
Expand Down
70 changes: 67 additions & 3 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
workflow_dispatch:

permissions:
contents: read
contents: write
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

The workflow permissions have been changed from "contents: read" to "contents: write". While this is necessary for the new publish-pages job to push to the gh-pages branch, it grants write access to the entire workflow, including the linux and windows jobs which only need read access. Consider using job-level permissions instead to follow the principle of least privilege, granting write access only to the publish-pages job.

Copilot uses AI. Check for mistakes.

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
group: benchmark-pages
cancel-in-progress: false
Comment on lines +10 to +11
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

The concurrency settings have been changed to use a static group name "benchmark-pages" with cancel-in-progress set to false. This means all benchmark workflow runs (regardless of the branch or trigger) will be grouped together and will not cancel each other. If multiple workflow runs are triggered (e.g., from different branches or manual triggers), they will queue up and run sequentially rather than canceling previous runs. Consider if this is the intended behavior, as it could lead to a queue of benchmark runs if triggered frequently.

Suggested change
group: benchmark-pages
cancel-in-progress: false
group: benchmark-pages-${{ github.ref }}
cancel-in-progress: true

Copilot uses AI. Check for mistakes.

jobs:
linux:
Expand Down Expand Up @@ -119,3 +119,67 @@ jobs:
benchmarks/bench_IsPrime.jpg
benchmarks/bench_IsPrimeNoTable.jpg
benchmarks/bench_summary.jpg

publish-pages:
name: Publish benchmark results to GitHub Pages
runs-on: ubuntu-latest
needs: [linux, windows]
steps:
- name: Download benchmark artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: benchmark-*

- name: Prepare Pages content
shell: bash
run: |
set -euo pipefail
RUN_ID="${GITHUB_RUN_ID}"
OUT_DIR="site/benchmarks/runs/${RUN_ID}"

mkdir -p "${OUT_DIR}"

# Keep artifact directories separated to avoid collisions.
for d in artifacts/*; do
if [ -d "$d" ]; then
name="$(basename "$d")"
mkdir -p "${OUT_DIR}/${name}"
cp -R "$d"/* "${OUT_DIR}/${name}"/ || true
Copy link

Copilot AI Dec 21, 2025

Choose a reason for hiding this comment

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

The bash command uses "cp -R" with "|| true" which silently ignores all copy failures. If there are permission issues, missing files, or other problems during the copy operation, they will be suppressed without any indication. Consider using proper error handling or at least logging a warning when the copy fails, so that issues can be diagnosed.

Suggested change
cp -R "$d"/* "${OUT_DIR}/${name}"/ || true
# Only attempt to copy if the artifact directory is non-empty.
if compgen -G "$d/*" > /dev/null; then
if ! cp -R "$d"/* "${OUT_DIR}/${name}/"; then
echo "warning: failed to copy contents of '$d' to '${OUT_DIR}/${name}/'" >&2
exit 1
fi
fi

Copilot uses AI. Check for mistakes.
fi
done

# No Jekyll processing (serve files as-is)
touch site/.nojekyll

# Write pointer to the latest run.
python3 - <<'PY'
import json, os
repo = os.environ.get('GITHUB_REPOSITORY', '')
run_id = int(os.environ.get('GITHUB_RUN_ID', '0'))
run_url = f"https://github.com/{repo}/actions/runs/{run_id}" if repo and run_id else None
artifacts_dir = 'artifacts'
artifacts = []
if os.path.isdir(artifacts_dir):
for name in sorted(os.listdir(artifacts_dir)):
full = os.path.join(artifacts_dir, name)
if os.path.isdir(full) and name.startswith('benchmark-'):
artifacts.append(name)
data = {
'runId': run_id,
'runUrl': run_url,
'artifacts': artifacts,
}
os.makedirs('site/benchmarks', exist_ok=True)
with open('site/benchmarks/latest.json', 'w', encoding='utf-8') as f:
json.dump(data, f, ensure_ascii=False, indent=2)
PY

- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: site
keep_files: true
commit_message: "chore(bench): publish run ${{ github.run_id }}"
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ The benchmark is run on GitHub Actions' Linux with gcc with -O3 optimization ena

You can find more detailed benchmark results by clicking [here](https://github.com/Rac75116/libcpprime/actions/workflows/bench.yml?query=branch%3Amain+is%3Acompleted).


![bench_IsPrime](bench_results/bench_IsPrime.jpg)
![bench_IsPrimeNoTable](bench_results/bench_IsPrimeNoTable.jpg)
![bench_summary](bench_results/bench_summary.jpg)

# Releases

- 2025/12/21 ver 1.3.0
Expand Down
Binary file removed bench_results/bench_IsPrime.jpg
Binary file not shown.
Binary file removed bench_results/bench_IsPrimeNoTable.jpg
Binary file not shown.
Binary file removed bench_results/bench_summary.jpg
Binary file not shown.