Skip to content

Commit

Permalink
Jmeterbenchmark
Browse files Browse the repository at this point in the history
test jmeter benchmarking

Signed-off-by: ruzell22 <ruzell.vince.aquino@accenture.com>
  • Loading branch information
ruzell22 committed Dec 5, 2023
1 parent afc751f commit b01e243
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 17 deletions.
84 changes: 68 additions & 16 deletions .github/workflows/jmeter-benchmarking.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: JMH Benchmark
name: Benchmark.js Example
on:
push:
branches:
Expand All @@ -13,22 +13,74 @@ permissions:

jobs:
benchmark:
name: Run JMH benchmark example
name: Run JavaScript benchmark example
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v2
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: Run benchmark
run: cd examples/benchmarkjs && npm install && node bench.js | tee output.txt

- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
with:
distribution: 'adopt'
java-version: '11'
- name: Cache SBT dependencies
uses: coursier/cache-action@v6
- name: Build and run JMH benchmark
run: |
sbt clean compile
sbt 'benchmarks/jmh:run -i 1 -wi 0 -f1 -t1 -rf json -rff output.json .*'
- name: JMH Benchmark Action
uses: kitlangton/jmh-benchmark-action@main
name: Benchmark.js Benchmark
tool: 'benchmarkjs'
output-file-path: examples/benchmarkjs/output.txt
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@ktrz'

- name: Store benchmark result - separate results repo
uses: benchmark-action/github-action-benchmark@v1
with:
jmh-output-path: benchmarks/output.json
github-token: ${{ secrets.GITHUB_TOKEN }}
name: Benchmark.js Benchmark
tool: 'benchmarkjs'
output-file-path: examples/benchmarkjs/output.txt
github-token: ${{ secrets.BENCHMARK_ACTION_BOT_TOKEN }}
auto-push: true
# Show alert with commit comment on detecting possible performance regression
alert-threshold: '200%'
comment-on-alert: true
fail-on-alert: true
alert-comment-cc-users: '@ktrz'
gh-repository: 'github.com/benchmark-action/github-action-benchmark-results'

# name: JMH Benchmark
# on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main

# permissions:
# contents: write
# deployments: write

# jobs:
# benchmark:
# name: Run JMH benchmark example
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-java@v2
# with:
# distribution: 'adopt'
# java-version: '11'
# - name: Cache SBT dependencies
# uses: coursier/cache-action@v6
# - name: Build and run JMH benchmark
# run: |
# sbt clean compile
# sbt 'benchmarks/jmh:run -i 1 -wi 0 -f1 -t1 -rf json -rff output.json .*'
# - name: JMH Benchmark Action
# uses: kitlangton/jmh-benchmark-action@main
# with:
# jmh-output-path: benchmarks/output.json
# github-token: ${{ secrets.GITHUB_TOKEN }}
15 changes: 15 additions & 0 deletions bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const Benchmark = require('benchmark');
const suite = new Benchmark.Suite();
const { fib } = require('./index');

suite
.add("fib(10)", () => {
fib(10);
})
.add("fib(20)", () => {
fib(20);
})
.on("cycle", (event) => {
console.log(String(event.target));
})
.run();
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function fib(n) {
if (n <= 1) {
return 1;
}
return fib(n - 2) + fib(n - 1);
}

exports.fib = fib;
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"prettier": "prettier --write --config .prettierrc.js \"./**/src/main/json/openapi.json\"",
"lerna-publish-canary": "lerna publish --canary --force-publish --dist-tag $(git branch --show-current) --preid $(git branch --show-current) --loglevel=silly",
"prepare": "husky install",
"init-registries": "npm config set @iroha2:registry=https://nexus.iroha.tech/repository/npm-group/"
"init-registries": "npm config set @iroha2:registry=https://nexus.iroha.tech/repository/npm-group/",
"test": "echo \"Error: no test specified\" && exit 1"
},
"resolutions": {
"ansi-html": ">0.0.8",
Expand Down Expand Up @@ -110,6 +111,7 @@
"@typescript-eslint/eslint-plugin": "6.4.0",
"@typescript-eslint/parser": "6.4.0",
"adm-zip": "0.5.10",
"benchmark": "^2.1.4",
"buffer": "6.0.3",
"cpy-cli": "4.2.0",
"cross-env": "7.0.3",
Expand Down

0 comments on commit b01e243

Please sign in to comment.