Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: added push WRK output into the bencher #2001

Closed
wants to merge 8 commits into from
Closed
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
19 changes: 19 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,22 @@ jobs:
with:
name: body
path: ci-benchmark/body.md

- name: Generate BMF JSON
working-directory: ci-benchmark
run: python generate_bmf_json.py wrk-output.txt

- uses: bencherdev/bencher@main
- name: Push to Bencher.dev
run: |
bencher run \
--project tailcall \
--token '${{ secrets.BENCHER_API_TOKEN }}' \
--branch '${{ github.head_ref }}' \
--branch-start-point '${{ github.base_ref }}' \
--branch-start-point-hash '${{ github.base_sha }}' \
--testbed ubuntu-latest \
--adapter json \
--err \
--file "results.json"
--github-actions '${{ secrets.GITHUB_TOKEN }}' \
33 changes: 33 additions & 0 deletions ci-benchmark/generate_bmf_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import json
import re

def parse_wrk_output(file_path):
data = {}
with open(file_path, 'r') as file:
content = file.readlines()
for line in content:
if "Latency" in line:
# Example: Latency 88.0ms, 87.42ms, 88.88ms
match = re.search(r"Latency (\d+\.\d+)ms, (\d+\.\d+)ms, (\d+\.\d+)ms", line)
if match:
data['latency'] = float(match.group(1))
data['latency_lower'] = float(match.group(2))
data['latency_upper'] = float(match.group(3))
return data

def generate_bmf_json(data):
bmf_json = {
"my_benchmark": {
"latency": {
"value": data["latency"],
"lower_value": data["latency_lower"],
"upper_value": data["latency_upper"]
}
}
}
return bmf_json
# Example usage
wrk_data = parse_wrk_output('wrk_output.txt')
bmf_data = generate_bmf_json(wrk_data)
Copy link
Contributor

Choose a reason for hiding this comment

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

with open('results.json', 'w') as f:
json.dump(bmf_data, f, indent=4)
Loading