Skip to content

Commit 69c23bf

Browse files
committed
Jmeterbenchmark
test jmeter benchmarking Signed-off-by: ruzell22 <[email protected]>
1 parent afc751f commit 69c23bf

File tree

6 files changed

+117
-18
lines changed

6 files changed

+117
-18
lines changed
+74-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: JMH Benchmark
1+
name: Benchmark.js Example
22
on:
33
push:
44
branches:
@@ -13,22 +13,79 @@ permissions:
1313

1414
jobs:
1515
benchmark:
16-
name: Run JMH benchmark example
16+
name: Run JavaScript benchmark example
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v3
20-
- uses: actions/setup-java@v2
21-
with:
22-
distribution: 'adopt'
23-
java-version: '11'
24-
- name: Cache SBT dependencies
25-
uses: coursier/cache-action@v6
26-
- name: Build and run JMH benchmark
27-
run: |
28-
sbt clean compile
29-
sbt 'benchmarks/jmh:run -i 1 -wi 0 -f1 -t1 -rf json -rff output.json .*'
30-
- name: JMH Benchmark Action
31-
uses: kitlangton/jmh-benchmark-action@main
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-node@v1
21+
- name: Run benchmark
22+
run: cd examples/benchmarkjs && npm install && node bench.js | tee output.txt
23+
24+
- name: Store benchmark result
25+
uses: benchmark-action/github-action-benchmark@v1
3226
with:
33-
jmh-output-path: benchmarks/output.json
34-
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
tool: 'benchmarkjs'
28+
output-file-path: output.txt
29+
30+
# - name: Store benchmark result
31+
# uses: benchmark-action/github-action-benchmark@v1
32+
# with:
33+
# name: Benchmark.js Benchmark
34+
# tool: 'benchmarkjs'
35+
# output-file-path: examples/benchmarkjs/output.txt
36+
# github-token: ${{ secrets.GITHUB_TOKEN }}
37+
# auto-push: true
38+
# # Show alert with commit comment on detecting possible performance regression
39+
# alert-threshold: '200%'
40+
# comment-on-alert: true
41+
# fail-on-alert: true
42+
43+
# - name: Store benchmark result - separate results repo
44+
# uses: benchmark-action/github-action-benchmark@v1
45+
# with:
46+
# name: Benchmark.js Benchmark
47+
# tool: 'benchmarkjs'
48+
# output-file-path: examples/benchmarkjs/output.txt
49+
# github-token: ${{ secrets.BENCHMARK_ACTION_BOT_TOKEN }}
50+
# auto-push: true
51+
# # Show alert with commit comment on detecting possible performance regression
52+
# alert-threshold: '200%'
53+
# comment-on-alert: true
54+
# fail-on-alert: true
55+
# alert-comment-cc-users: '@ktrz'
56+
# gh-repository: 'github.com/benchmark-action/github-action-benchmark-results'
57+
58+
# name: JMH Benchmark
59+
# on:
60+
# push:
61+
# branches:
62+
# - main
63+
# pull_request:
64+
# branches:
65+
# - main
66+
67+
# permissions:
68+
# contents: write
69+
# deployments: write
70+
71+
# jobs:
72+
# benchmark:
73+
# name: Run JMH benchmark example
74+
# runs-on: ubuntu-latest
75+
# steps:
76+
# - uses: actions/checkout@v3
77+
# - uses: actions/setup-java@v2
78+
# with:
79+
# distribution: 'adopt'
80+
# java-version: '11'
81+
# - name: Cache SBT dependencies
82+
# uses: coursier/cache-action@v6
83+
# - name: Build and run JMH benchmark
84+
# run: |
85+
# sbt clean compile
86+
# sbt 'benchmarks/jmh:run -i 1 -wi 0 -f1 -t1 -rf json -rff output.json .*'
87+
# - name: JMH Benchmark Action
88+
# uses: kitlangton/jmh-benchmark-action@main
89+
# with:
90+
# jmh-output-path: benchmarks/output.json
91+
# github-token: ${{ secrets.GITHUB_TOKEN }}

examples/benchmarkjs/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
/package-lock.json

examples/benchmarkjs/bench.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const Benchmark = require('benchmark');
2+
const suite = new Benchmark.Suite();
3+
const { fib } = require('./index');
4+
5+
suite
6+
.add("fib(10)", () => {
7+
fib(10);
8+
})
9+
.add("fib(20)", () => {
10+
fib(20);
11+
})
12+
.on("cycle", (event) => {
13+
console.log(String(event.target));
14+
})
15+
.run();

examples/benchmarkjs/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
function fib(n) {
2+
if (n <= 1) {
3+
return 1;
4+
}
5+
return fib(n - 2) + fib(n - 1);
6+
}
7+
8+
exports.fib = fib;

examples/benchmarkjs/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "benchmark-example",
3+
"private": true,
4+
"version": "0.0.0",
5+
"description": "",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"author": "rhysd <[email protected]> (https://rhysd.github.io/)",
11+
"license": "MIT",
12+
"devDependencies": {
13+
"benchmark": "^2.1.4"
14+
}
15+
}

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
"prettier": "prettier --write --config .prettierrc.js \"./**/src/main/json/openapi.json\"",
7575
"lerna-publish-canary": "lerna publish --canary --force-publish --dist-tag $(git branch --show-current) --preid $(git branch --show-current) --loglevel=silly",
7676
"prepare": "husky install",
77-
"init-registries": "npm config set @iroha2:registry=https://nexus.iroha.tech/repository/npm-group/"
77+
"init-registries": "npm config set @iroha2:registry=https://nexus.iroha.tech/repository/npm-group/",
78+
"test": "echo \"Error: no test specified\" && exit 1"
7879
},
7980
"resolutions": {
8081
"ansi-html": ">0.0.8",
@@ -110,6 +111,7 @@
110111
"@typescript-eslint/eslint-plugin": "6.4.0",
111112
"@typescript-eslint/parser": "6.4.0",
112113
"adm-zip": "0.5.10",
114+
"benchmark": "^2.1.4",
113115
"buffer": "6.0.3",
114116
"cpy-cli": "4.2.0",
115117
"cross-env": "7.0.3",

0 commit comments

Comments
 (0)