当前位置:网站首页>Simple operation K6
Simple operation K6
2022-07-24 23:48:00 【Clean night mortal dust】
function k6
Run local tests
Copy the following code , Save as
script.js
import http from 'k6/http';
import {
sleep } from 'k6';
export default function () {
http.get('https://test.k6.io');
sleep(1);
}
Began to run
1.Linux CLI
k6 run script.js
2.Docker run
docker run -i loadimpact/k6 run - <script.js
3.Windows docker run
PS C:\> cat script.js | docker run -i loadimpact/k6 run -
The effect is as follows

Add more VUs( user )
Try to use 10 Virtual users and slightly longer duration to run load tests
1.Linux CLI
k6 run --vus 10 --duration 30s script.js
2.Docker run
docker run -i loadimpact/k6 run --vus 10 --duration 30s - <script.js
3.Windows docker run
PS C:\> cat script.js | docker run -i loadimpact/k6 run --vus 10 --duration 30s -
It's defined in JavaScript In file
import http from 'k6/http';
import {
sleep } from 'k6';
export let options = {
// vus --> user
vus: 10,
// duration --> The duration of the
duration: '30s',
};
export default function () {
http.get('http://test.k6.io');
sleep(1);
}
As the time period decreases vus
import http from 'k6/http';
import {
check, sleep } from 'k6';
export let options = {
stages: [
{
duration: '30s', target: 20 },
{
duration: '1m30s', target: 10 },
{
duration: '20s', target: 0 },
],
};
export default function () {
let res = http.get('https://httpbin.org/');
check(res, {
'status was 200': (r) => r.status == 200 });
sleep(1);
}
The effect is as follows

Results output
standard output , It will show k6 Signs and the following test information :
- Test details : General test information and load options .
- Progress bar : Test status and how much time has passed .
- Test summary : test result ( After the test is completed ). from k6 v0.30.0 Start , You can completely customize the output and redirect it to a file . You can also save any file using a machine-readable version of the summary , Such as JSON、XML( for example JUnit、XUnit etc. ), Even well formed for humans HTML The report ! For more details , See handle summary () file .
Details of operating parameters
execution: Local Show k6 Execution mode ( Local or cloud ).
output: - It is the output of granularity test results . By default , Do not use any output , Only the summary of the end of the test summarized .
script: route / To /script.js Displays the name of the script file being executed .
scenarios:… Is a summary of the scenario in which this test run will be executed and some overview information :
(100.00%) Is the execution segment used
50 The biggest VU Tell us how much will be used in all scenarios VU( Virtual user ).
Maximum duration 5 branch 30 Seconds is the longest time for the script to run , Including any normal stop time .
default: … Describes the only scenario for this test run . under these circumstances , It is a slope VU Scenario of actuator , Use the stage shortcut option instead of the scene long format option .
External output
Use --out Export to external
Currently, the built-in available types are :cloud、csv、influxdb、json、statsd
# demonstration : Output into json, And save to test.json In file
k6 run --out json=test.json script.js
Of course It also supports multi output
k6 run --out json=test.json \
--out csv=test.csv script.js
Refer to official documentation
Official document address : https://k6.io/docs/
边栏推荐
- Network Security Learning (II) IP address
- 理财产品可以达到百分之6的,我想要开户买理财产品
- [brother hero July training] day 20: search Binary Tree
- Salesforce zero foundation learning (116) workflow - & gt; On flow
- Only by learning these JMeter plug-ins can we design complex performance test scenarios
- Upgrade the jdbc driver to version 8.0.28 and connect to the pit record of MySQL
- Where are MySQL version numbers 6 and 7?
- Is the income of CICC securities' new financial products 6%? I want to open an account and manage money
- 2022 the most NB JVM foundation to tuning notes, thoroughly understand Alibaba P6 small case
- SQL result export function. If you click the work order but don't enter it, the interface is always blank and there is no response. What should you do?
猜你喜欢

Notes of Teacher Li Hongyi's 2020 in-depth learning series 3

HLS编程入门

ES6 adds -iterator traversal, for..Of loop

Video chat source code - one-to-one live broadcast system source code

Only by learning these JMeter plug-ins can we design complex performance test scenarios

Beisen prospectus: the advantages of the track are prominent, and integration + medium and large customers are plus points

Notes of Teacher Li Hongyi's 2020 in-depth learning series 9

Network Security Learning (V) DHCP

50 places are limited to open | with the news of oceanbase's annual press conference coming!

Paper time review MB2: build a behavior model for autonomous databases
随机推荐
BGP related knowledge points
Lidar obstacle detection and tracking: CUDA European clustering
Upgrade the jdbc driver to version 8.0.28 and connect to the pit record of MySQL
多线程&高并发(全网最新:面试题 + 导图 + 笔记)面试手稳心不慌
Processing PDF and JPG files in VB6
Power consumption of chip
Piziheng embedded: the method of making source code into lib Library under MCU Xpress IDE and its difference with IAR and MDK
Google Earth engine - the use of the neighborhood tobands function
dpkg : Breaks: libapt-pkg5.0 (< 1.7~b) but 1.6.15 is to be installedE: Broken packages
c语言:深度刨析函数栈帧
Weekly summary (*66): next five years
ShardingSphere-数据库分库分表简介
91. (leaflet chapter) leaflet situation plotting - offensive direction drawing
The idea of Google's "Ai awareness" event this month
cloud chart
Code coverage
SQLite database operation
谢振东:公共交通行业数字化转型升级的探索与实践
Answers to some problems encountered in the process of Xperia XZ (f8332) brushing and root
Paper time review MB2: build a behavior model for autonomous databases