Skip to content

Commit

Permalink
Add k6 benchmark example.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 1, 2025
1 parent 349e724 commit d10f485
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
18 changes: 18 additions & 0 deletions examples/benchmark/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Benchmark Example

## Usage

First, ensure you have `k6` installed. Then, start the server:

```bash
$ falcon serve --bind http://localhost:9292
```

Then run `k6`:

```bash
$ k6 run small.js
```
## Comparison

You could start the included `config.ru` with other servers and compare.
21 changes: 21 additions & 0 deletions examples/benchmark/small.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const options = {
stages: [
// Warmup: Gradually ramp up:
{duration: '10s', target: 64},

// Main test: Sustained load:
{duration: '1m', target: 64},
],
};

import http from 'k6/http';
import { check, sleep } from 'k6';

export default function () {
const res = http.get('http://localhost:9292/small');

check(res, {
'is status 200': (r) => r.status === 200,
'response time < 200ms': (r) => r.timings.duration < 200,
});
}

0 comments on commit d10f485

Please sign in to comment.