From 0b1bbf34cc8e6d50626bd35b98cfd20af43a8246 Mon Sep 17 00:00:00 2001 From: M-Vamshi <21211a05f1@bvrit.ac.in> Date: Tue, 21 May 2024 19:00:00 +0530 Subject: [PATCH 1/4] added push WRK output into the bencher --- .github/workflows/benchmark.yml | 23 +++++++++++++++++++-- ci-benchmark/generate_bmf_json.py | 34 +++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 ci-benchmark/generate_bmf_json.py diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d437f9899c..bdd8cb5bf1 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -2,11 +2,11 @@ name: Benchmark on: push: - paths-ignore: ["docs/**", "**.md"] + paths-ignore: ["docs/", ".md"] branches: - main pull_request: - paths-ignore: ["docs/**", "**.md"] + paths-ignore: ["docs/", ".md"] types: [opened, reopened, synchronize, labeled] concurrency: @@ -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 }}' \ \ No newline at end of file diff --git a/ci-benchmark/generate_bmf_json.py b/ci-benchmark/generate_bmf_json.py new file mode 100644 index 0000000000..b2dd581299 --- /dev/null +++ b/ci-benchmark/generate_bmf_json.py @@ -0,0 +1,34 @@ +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) +with open('results.json', 'w') as f: + json.dump(bmf_data, f, indent=4) \ No newline at end of file From 9fbd6ca87cc615f0589092acf2a3df8017f6cad6 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Tue, 21 May 2024 19:07:24 +0530 Subject: [PATCH 2/4] fix lint --- .github/workflows/benchmark.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index bdd8cb5bf1..36ccefa472 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -2,11 +2,11 @@ name: Benchmark on: push: - paths-ignore: ["docs/", ".md"] + paths-ignore: ["docs/**", "**.md/"] branches: - main pull_request: - paths-ignore: ["docs/", ".md"] + paths-ignore: ["docs/**", "**.md"] types: [opened, reopened, synchronize, labeled] concurrency: @@ -86,4 +86,4 @@ jobs: --adapter json \ --err \ --file "results.json" - --github-actions '${{ secrets.GITHUB_TOKEN }}' \ \ No newline at end of file + --github-actions '${{ secrets.GITHUB_TOKEN }}' \ From 9b5955fd1dd408cac53ef3f696a5a5f7e28a0069 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Tue, 21 May 2024 19:07:45 +0530 Subject: [PATCH 3/4] Update benchmark.yml --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 36ccefa472..69b0934530 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -2,7 +2,7 @@ name: Benchmark on: push: - paths-ignore: ["docs/**", "**.md/"] + paths-ignore: ["docs/**", "**.md"] branches: - main pull_request: From f6ceda9e610ff99187e89499ec21151aaf551bf4 Mon Sep 17 00:00:00 2001 From: Vamshi Maskuri <117595548+varshith257@users.noreply.github.com> Date: Tue, 21 May 2024 19:31:44 +0530 Subject: [PATCH 4/4] fix lint --- ci-benchmark/generate_bmf_json.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci-benchmark/generate_bmf_json.py b/ci-benchmark/generate_bmf_json.py index b2dd581299..b7b837dd14 100644 --- a/ci-benchmark/generate_bmf_json.py +++ b/ci-benchmark/generate_bmf_json.py @@ -26,9 +26,8 @@ def generate_bmf_json(data): } } return bmf_json - # Example usage wrk_data = parse_wrk_output('wrk_output.txt') bmf_data = generate_bmf_json(wrk_data) with open('results.json', 'w') as f: - json.dump(bmf_data, f, indent=4) \ No newline at end of file + json.dump(bmf_data, f, indent=4)