Skip to content

Commit

Permalink
setup k6 cloud to upload results
Browse files Browse the repository at this point in the history
Signed-off-by: Sahil Yeole <[email protected]>
  • Loading branch information
beelchester committed Jul 4, 2024
1 parent 3aaf778 commit 7d299e3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
if: github.event.head_commit.message != 'Update performance results in README.md'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
K6_CLOUD_API_TOKEN: ${{ secrets.K6_CLOUD_API_TOKEN }}
steps:
- name: Checkout (GitHub)
uses: actions/checkout@v4
Expand All @@ -34,6 +35,16 @@ jobs:
- name: Setup k6
uses: grafana/setup-k6-action@v1

- name: Setup k6 cloud environment
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
if [ -z "$K6_CLOUD_API_TOKEN" ]; then
echo "K6_CLOUD_API_TOKEN is not set, results will not be uploaded to k6 cloud"
else
k6 login cloud --token $K6_CLOUD_API_TOKEN
echo "IS_K6_CLOUD_ENABLED=true" >> $GITHUB_ENV
fi
- name: Run benchmarks
run: |
bash ./setup.sh
Expand Down
7 changes: 4 additions & 3 deletions k6/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import http from 'k6/http';
import { check } from 'k6';

const whichBenchmark = Number(__ENV.BENCHMARK);
const benchmarkName = whichBenchmark === 1 ? 'posts' : 'posts+users';

export const options = {
scenarios: {
posts: {
executor: 'constant-vus',
duration: whichBenchmark === 2 ? '30s' : '10s',
duration: whichBenchmark === 1 ? '10s' : '30s',
gracefulStop: '0s',
vus: 100,
}
},
cloud: {
name: __ENV.TEST_NAME + '-' + whichBenchmark,
name: __ENV.TEST_NAME + '-' + benchmarkName,
},
};

Expand All @@ -30,7 +31,7 @@ export default function() {
const payload = JSON.stringify({
operationName: null,
variables: {},
query: whichBenchmark === 2 ? '{posts{id,userId,title,user{id,name,email}}}' : '{posts{title}}',
query: whichBenchmark === 1 ? '{posts{title}}' : '{posts{id,userId,title,user{id,name,email}}}',
});

const res = http.post(url, payload, params);
Expand Down
7 changes: 5 additions & 2 deletions k6/bench.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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
if [ "$IS_K6_CLOUD_ENABLED" == "true" ]; then
k6 run k6/bench.js --quiet --out cloud --env TEST_NAME=$test_name --env BENCHMARK=$benchmark
else
k6 run k6/bench.js --quiet --env TEST_NAME=$test_name --env BENCHMARK=$benchmark
fi

3 comments on commit 7d299e3

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark 1 results

Server Requests/sec Latency (ms)
[Tailcall] -nan -nan
[Netflix DGS] -nan -nan
[Gqlgen] -nan -nan
[Caliban] -nan -nan
[async-graphql] -nan -nan
[Apollo GraphQL] -nan -nan

Benchmark 2 results

Server Requests/sec Latency (ms)
[Tailcall] -nan -nan
[Netflix DGS] -nan -nan
[Gqlgen] -nan -nan
[Caliban] -nan -nan
[async-graphql] -nan -nan
[Apollo GraphQL] -nan -nan

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark 1 results

Server Requests/sec Latency (ms)
[Tailcall] -nan -nan
[Netflix DGS] -nan -nan
[Gqlgen] -nan -nan
[Caliban] -nan -nan
[async-graphql] -nan -nan
[Apollo GraphQL] -nan -nan

Benchmark 2 results

Server Requests/sec Latency (ms)
[Tailcall] -nan -nan
[Netflix DGS] -nan -nan
[Gqlgen] -nan -nan
[Caliban] -nan -nan
[async-graphql] -nan -nan
[Apollo GraphQL] -nan -nan

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark 1 results

Server Requests/sec Latency (ms)
[Tailcall] -nan -nan
[Netflix DGS] -nan -nan
[Gqlgen] -nan -nan
[Caliban] -nan -nan
[async-graphql] -nan -nan
[Apollo GraphQL] -nan -nan

Benchmark 2 results

Server Requests/sec Latency (ms)
[Tailcall] -nan -nan
[Netflix DGS] -nan -nan
[Gqlgen] -nan -nan
[Caliban] -nan -nan
[async-graphql] -nan -nan
[Apollo GraphQL] -nan -nan

Please sign in to comment.