Skip to content

Commit

Permalink
refactor: place all benchmarks in subdir
Browse files Browse the repository at this point in the history
  • Loading branch information
leon0399 committed Jul 31, 2024
1 parent edfc74a commit 2492036
Show file tree
Hide file tree
Showing 115 changed files with 26 additions and 11 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/benchmark_on_change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ name: Run Benchmark on Change

on:
pull_request:
branches:
- master
paths:
- 'langs/**/*'
- '.github/workflows/benchmark_on_change.yml'
- 'benchmark.py'
- 'run_on_changes.py'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
benchmark:
runs-on: ubuntu-latest
timeout-minutes: 60

permissions:
pull-requests: read
Expand All @@ -33,7 +39,5 @@ jobs:
- name: Run benchmarks for changed files
if: steps.changed-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
docker-compose run benchmark python3 ./run_on_changes.py $ALL_CHANGED_FILES
docker-compose run benchmark python3 ./run_on_changes.py ${{ steps.changed-files.outputs.all_changed_files }}
9 changes: 9 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
paths:
- Dockerfile

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}

jobs:
docker:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -50,7 +53,13 @@ jobs:
- name: Build and push
uses: docker/build-push-action@v6
with:
pull: true
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: |
${{ steps.meta.outputs.tags }}
ghcr.io/${{ github.repository }}:latest
type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
4 changes: 2 additions & 2 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
configurations = []
if args.languages:
for language in args.languages:
configurations += glob.glob(language + '/benchmark.yml') + glob.glob(language + '/benchmark.yaml')
configurations += glob.glob('langs' + language + '/benchmark.yml') + glob.glob('langs' + language + '/benchmark.yaml')
else:
configurations = glob.glob('*/benchmark.yml') + glob.glob('*/benchmark.yaml')
configurations = glob.glob('langs/*/benchmark.yml') + glob.glob('langs/*/benchmark.yaml')
configurations.sort()

scripts = ['*']
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions run_on_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
benchmark_commands = set()
for file_path in changed_files:
parts = file_path.split('/')
if len(parts) < 3:
if len(parts) < 4 or parts[0] != 'langs':
continue # Skip invalid paths
language, category, script = parts[0], parts[1], parts[2]
language, category, script = parts[1], parts[2], parts[3]
script_name = script.split('.')[0] # Extract script name without extension
# Assuming the benchmark script supports language and script parameters
command = f"python3 ./benchmark.py --languages {language} --scripts {category}/{script_name} --times 1"
command = f"python3 ./benchmark.py run --languages {language} --scripts {category}/{script_name} --times 1"
benchmark_commands.add(command)

# Executing benchmark commands
for command in benchmark_commands:
print(f"Executing: {command}")
subprocess.run(command, shell=True)
result = subprocess.run(command, shell=True)
if result.returncode != 0:
sys.exit(f"Command failed: {command}")

0 comments on commit 2492036

Please sign in to comment.