Skip to content

Commit 67bffa0

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

File tree

5 files changed

+110
-19
lines changed

5 files changed

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

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)