-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sahil Yeole <[email protected]>
- Loading branch information
1 parent
5592580
commit fd2e11d
Showing
9 changed files
with
77 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,14 +25,19 @@ jobs: | |
token: ${{ secrets.GITHUB_TOKEN }} | ||
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} | ||
|
||
- name: Build devcontainer and run benchmarks | ||
- name: Build devcontainer | ||
uses: devcontainers/[email protected] | ||
with: | ||
imageName: graphql-benchmarks | ||
push: never | ||
runCmd: | | ||
bash ./setup.sh | ||
bash ./run_benchmarks.sh | ||
|
||
- name: Setup k6 | ||
uses: grafana/setup-k6-action@v1 | ||
|
||
- name: Run benchmarks | ||
run: | | ||
bash ./setup.sh | ||
bash ./run_benchmarks.sh | ||
- name: Print benchmark results | ||
run: cat ./results.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import http from 'k6/http'; | ||
import { check } from 'k6'; | ||
|
||
const whichBenchmark = Number(__ENV.BENCHMARK); | ||
|
||
export const options = { | ||
scenarios: { | ||
posts: { | ||
executor: 'constant-vus', | ||
duration: whichBenchmark === 2 ? '30s' : '10s', | ||
gracefulStop: '0s', | ||
vus: 100, | ||
} | ||
}, | ||
cloud: { | ||
name: __ENV.TEST_NAME + '-' + whichBenchmark, | ||
}, | ||
}; | ||
|
||
const url = 'http://localhost:8000/graphql'; | ||
const params = { | ||
headers: { | ||
'Connection': 'keep-alive', | ||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36', | ||
'Content-Type': 'application/json', | ||
}, | ||
}; | ||
|
||
export default function() { | ||
const payload = JSON.stringify({ | ||
operationName: null, | ||
variables: {}, | ||
query: whichBenchmark === 2 ? '{posts{id,userId,title,user{id,name,email}}}' : '{posts{title}}', | ||
}); | ||
|
||
const res = http.post(url, payload, params); | ||
check(res, { | ||
'status is 200': (r) => r.status === 200, | ||
}); | ||
} | ||
|
||
export function handleSummary(data) { | ||
const med_request_count = data.metrics.http_reqs.values.count; | ||
const avg_latency = data.metrics.http_req_duration.values.avg; | ||
const trimmed_avg_latency = Math.round(avg_latency * 100) / 100; | ||
const request_count_message = `Requests/sec: ${med_request_count}\n`; | ||
const latency_message = `Latency: ${trimmed_avg_latency} ms\n`; | ||
|
||
return { | ||
stdout: request_count_message + latency_message, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test_name=$1 | ||
benchmark=$2 | ||
|
||
# k6 run k6/bench.js --quiet --out cloud --env TEST_NAME=$test_name --env BENCHMARK=$benchmark | ||
k6 run k6/bench.js --quiet --env TEST_NAME=$test_name --env BENCHMARK=$benchmark |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
k6 run k6/bench.js --quiet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.