diff --git a/examples/benchmark/readme.md b/examples/benchmark/readme.md new file mode 100644 index 0000000..8ab2091 --- /dev/null +++ b/examples/benchmark/readme.md @@ -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. diff --git a/examples/benchmark/small.js b/examples/benchmark/small.js new file mode 100644 index 0000000..38d70fe --- /dev/null +++ b/examples/benchmark/small.js @@ -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, + }); +} \ No newline at end of file