0%

k6

k6是一款高性能的负载测试工具,旨在在预生产和QA环境中以高负载运行测试,可使用JavaScript编写脚本。

1
2
3
4
5
6
7
8
9
10
11
12
import http from 'k6/http';
import { sleep, check } from 'k6';

export default function () {
const resp = http.get('https://httpbin.org/get');
check(resp, {
'status is 200': (r) => r.status === 200,
'less than 100ms': (r) => r.status === 200 && r.timings.duration <= 100,
'less than 500ms': (r) => r.status === 200 && r.timings.duration <= 500,
});
sleep(1);
}
1
docker run --rm -i loadimpact/k6 run --vus 100 --duration 300s - < script.js