kandi X-RAY | k6 Summary
kandi X-RAY | k6 Summary
A modern load testing tool for developers and testers in the DevOps era. Download · Install · Documentation · Community Forum. k6 is a modern load testing tool, building on our years of experience in the load and performance testing industry. It provides a clean, approachable scripting API, local and cloud execution, and flexible configuration. This is how load testing should look in the 21st century.
Top functions reviewed by kandi - BETA
k6 Key Features
k6 Examples and Code Snippets
Trending Discussions on k6
I'm trying to make sure gcc vectorizes my loops. It turns out, that by using
-march=native) gcc skips some loops even though they can be vectorized. Why does this happen?
In this code, the second loop, which multiplies each element by a scalar is not vectorised:...
ANSWERAnswered 2022-Apr-10 at 02:47
-mavx2 doesn't change that.
-mprefer-vector-width=128, because that's all the native width of the HW. An instruction using 32-byte YMM vectors decodes to at least 2 uops, more if it's a lane-crossing shuffle. For simple vertical SIMD like this, 32-byte vectors would be ok; the pipeline handles 2-uop instructions efficiently. (And I think is 6 uops wide but only 5 instructions wide, so max front-end throughput isn't available using only 1-uop instructions). But when vectorization would require shuffling, e.g. with arrays of different element widths, GCC code-gen can get messier with 256-bit or wider.
vmovdqa ymm0, ymm1 mov-elimination only works on the low 128-bit half on Zen1. Also, normally using 256-bit vectors would imply one should use
vzeroupper afterwards, to avoid performance problems on other CPUs (but not Zen1).
I don't know how Zen1 handles misaligned 32-byte loads/stores where each 16-byte half is aligned but in separate cache lines. If that performs well, GCC might want to consider increasing the znver1
-mprefer-vector-width to 256. But wider vectors means more cleanup code if the size isn't known to be a multiple of the vector width.
Ideally GCC would be able to detect easy cases like this and use 256-bit vectors there. (Pure vertical, no mixing of element widths, constant size that's am multiple of 32 bytes.) At least on CPUs where that's fine: znver1, but not bdver2 for example where 256-bit stores are always slow due to a CPU design bug.
You can see the result of this choice in the way it vectorizes your first loop, the memset-like loop, with a
vmovdqu [rdx], xmm0. https://godbolt.org/z/E5Tq7Gfzc
So given that GCC has decided to only use 128-bit vectors, which can only hold two
uint64_t elements, it (rightly or wrongly) decides it wouldn't be worth using
vpaddd to implement qword
(v<<2) + v, vs. doing it with integer in one LEA instruction.
Almost certainly wrongly in this case, since it still requires a separate load and store for every element or pair of elements. (And loop overhead since GCC's default is not to unroll except with PGO,
-fprofile-use. SIMD is like loop unrolling, especially on a CPU that handles 256-bit vectors as 2 separate uops.)
I'm not sure exactly what GCC means by "not vectorized: unsupported data-type". x86 doesn't have a SIMD
uint64_t multiply instruction until AVX-512, so perhaps GCC assigns it a cost based on the general case of having to emulate it with multiple 32x32 => 64-bit
pmuludq instructions and a bunch of shuffles. And it's only after it gets over that hump that it realizes that it's actually quite cheap for a constant like
5 with only 2 set bits?
That would explain GCC's decision-making process here, but I'm not sure it's exactly the right explanation. Still, these kinds of factors are what happen in a complex piece of machinery like a compiler. A skilled human can easily make smarter choices, but compilers just do sequences of optimization passes that don't always consider the big picture and all the details at the same time.
-mprefer-vector-width=256doesn't help: Not vectorizing
uint64_t *= 5seems to be a GCC9 regression
(The benchmarks in the question confirm that an actual Zen1 CPU gets a nearly 2x speedup, as expected from doing 2x uint64 in 6 uops vs. 1x in 5 uops with scalar. Or 4x uint64_t in 10 uops with 256-bit vectors, including two 128-bit stores which will be the throughput bottleneck along with the front-end.)
-march=znver1 -O3 -mprefer-vector-width=256, we don't get the
*= 5 loop vectorized with GCC9, 10, or 11, or current trunk. As you say, we do with
We do get vectorization with those options for
uint32_t (even leaving the vector width at 128-bit). Scalar would cost 4 operations per vector uop (not instruction), regardless of 128 or 256-bit vectorization on Zen1, so this doesn't tell us whether
*= is what makes the cost-model decide not to vectorize, or just the 2 vs. 4 elements per 128-bit internal uop.
uint64_t, changing to
arr[i] += arr[i]<<2; still doesn't vectorize, but
arr[i] <<= 1; does. (https://godbolt.org/z/6PMn93Y5G). Even
arr[i] <<= 2; and
arr[i] += 123 in the same loop vectorize, to the same instructions that GCC thinks aren't worth it for vectorizing
*= 5, just different operands, constant instead of the original vector again. (Scalar could still use one LEA). So clearly the cost-model isn't looking as far as final x86 asm machine instructions, but I don't know why
arr[i] += arr[i] would be considered more expensive than
arr[i] <<= 1; which is exactly the same thing.
GCC8 does vectorize your loop, even with 128-bit vector width: https://godbolt.org/z/5o6qjc7f6
I'm running into an issue when trying to compare data across two sheets to find discrepancies - specifically when it comes to comparing start and end times.
Right now, the "IF" statement in my screenshot is executing perfectly, except when a time is involved - it's reading those cells as decimals instead (but only sometimes).
I've tried formatting these cells (on the raw data AND on this "Discrepancies" report sheet) so that they are displayed as a "HH:MM am/pm" time, but the sheet is still comparing the decimal values.
Is there anything that I can add to this function to account for a compared value being a time instead of text, and having that text be compared for any discrepancies? I cannot add or change anything to the raw data sheets, the only thing I can edit is the formula seen in the screenshot I provided.
See the highlighted cells in my screenshot - this is the issue I keep running into. As you can see, there are SOME cells (the non-highlighted ones) that are executing as intended, but I'm unsure why this isn't the case for the whole spreadsheet when I've formatted everything the same way using the exact same formula across the whole sheet.
For example, the values in cell N2 is "8:00 AM" on both sheets, so the formula should just display "8:00 AM" in that cell (and NOT be highlighted) since there is no discrepancy in the cells between both sheets it's comparing. But instead, it's showing both times as a decimal with the slightest difference between them and is suggesting a difference where there technically isn't (or shouldn't be) one.
---EDIT (added the below):
Here is a view-only version of a SAMPLE SHEET that displays the issue I'm having: https://docs.google.com/spreadsheets/d/1BdSQGsCajB3kOnYxzM3sl-0o3iTvR3ABdHpnzYRXjpA/edit?usp=sharing
On the sample sheet, the only cells that are performing as intended are C2, E2, G2, I2, K2, K6, or any cells that contain text like "Closed". Any of the other cells that have a time in both raw data tabs appears to be pulling the serial numbers for those times instead of correctly formatting it into "HH:mm AM/PM".
A quick tour of how the SAMPLE SHEET is set up:
- User enters raw data into the "MicrositeRawData" and "SalesforceRawData" tabs.
- Data is pulled from the "SalesforceRawData" tab into the "CleanedUpSalesforceData" tab using a QUERY that matches the UNIQUE ID's from the "MicrositeRawData" sheet, so that it essentially creates a tab that's in the same order and accounts for any extraneous data between the tabs (keep in mind this is a sample sheet and that the original sheet I'm using includes a lot more data which causes a mismatch of rows between the sheets which makes the QUERY necessary).
- The "DISCREPANCIES" tab then compares the data between the "MicrositeRawData" and "CleanedUpSalesforceData" tabs. If the data is the same, it simply copies the data from the "MicrositeRawData" cell. But if the data is NOT the same, it lists the values from both sheets and is conditionally formatted to highlight those cells in yellow.
- If there is data on the "MicrositeRawData" tab that is NOT included on the "SalesforceRawData" tab, the "DISCREPANCIES" tab will notate that and highlight the "A" cell in pink instead of yellow (as demonstrated in "A5").
ANSWERAnswered 2022-Mar-26 at 09:48
try in B2:
I have a table where column A has the customer's data and column B has the customer's name. In columns C to L have the invoice information for that customer. I would like to get a vba code for when there is data in column A and B, create a row above the total and drag 1 row down the invoice information, looking like this:
A2 and B2 with the customer's code and name;
C3:L8 with customer invoice information;
Line nine: Total line (I already have this code)...
ANSWERAnswered 2022-Mar-14 at 07:47
Before you read this keep in mind the last time i actively programmed is like 4 years ago. Means the code is messy, not optimized, blah blah blah
So as requested to get a list like this:
to a format like this:
you can use the following code snippet. The "CommandButton1_Click()" function is only there because I use it as my trigger from a userform. the "adjustList" method can be called from wherever you like.
Basically I read all the customer data blocks into two dimensional arrays and clear the cells. After all entries are collected in the array and all cells are clear i write the data into the cells again with the requested format.
Also as requested this function can handle entries independent of how many rows they contain per customer, as shown in my screenshots.
I want to run a curl request as a pre-request script for my K6 load tests. Here is my YML file:...
ANSWERAnswered 2022-Mar-09 at 09:42
The k6 Docker image runs as an unprivileged user, which is why you're not able to install
I would suggest you to build your own custom image using
loadimpact/k6 as base, or to build an image from another base that copies the
k6 binary with
COPY --from=loadimpact/k6:latest /usr/bin/k6 /usr/bin/k6, install anything you need in it and run that image in CI instead.
I'm trying to write a PCLMULQDQ-optimized CRC-32 implementation. The specific CRC-32 variant is for one that I don't own, but am trying to support in library form. In crcany model form, it has the following parameters:
width=32 poly=0xaf init=0xffffffff refin=false refout=false xorout=0x00000000 check=0xa5fd3138
(Omitted residue which I believe is
0x00000000 but honestly don't know what it is)
A basic non-table-based/bitwise implementation of the algorithm (as generated by
ANSWERAnswered 2022-Mar-07 at 15:47
I have 6 sets of code for 16, 32, 64 bit crc, non-reflected and reflected here. The code is setup for Visual Studio. Comments have been added to the constants which were missing from Intel's github site.
32 bit non-relfected is here:
You'll need to change the polynomial in crc32fg.cpp, which generates the constants. The polynomial you want is actually:
I have two post request. This post request should run until the response is "createdIsCompleted" == false .I m taking createdIsCompleted response from second post isssue. So how can I run two requests in while loop. By the way, I have to wait first post issue before the second post issue should be run...I know there is no await operator in k6. But I want to learn alternative ways. This while loop not working as I want. The response still returns "createdIsCompleted" == true...
ANSWERAnswered 2022-Feb-19 at 11:38
By the way, I have to wait first post issue before the second post issue should be run...I know there is no await operator in k6
K6 currently has only blocking calls so each post will finish fully before the next one starts.
On the loop question you have two(three) problems:
createdISCompletedis unitialized, so the while loop will never be run as it's not
- you have big
Sin the declaration but then you have small
sin the while loop.
- you have
breakat the end of the loop which means it will always exit after the first iteration.
I am in the process of building a formula to split a total cost (in column J) based on start and end expenditure periods that can vary from 2021 to 2031. Based on the days between the expenditure period dates (column M), I managed to work out to split the cost using the formulas below up to 2023 but it is not consistent and at times incorrect.
In cell P5 I have the following formula. For year 2021, I seem to get the correct split result. =IF($K5>AS5,0,$J5/$M5*(AS5-$K5))
In cell Q5, I have the following formula. For year 2022, I seem to get the correct spit as well =MIN(IF(SUM($N5:P5)>=$J5,0,IF($L5>=AS5,$J5/$M5*(AS5-AR5),$J5/$M5*($L5-MAX(AR5,$K5)))),K5)
However, I don't get the right result in cell Q6 which has the same formula but different dates =MIN(IF(SUM($N6:P6)>=$J6,0,IF($L6>=AS6,$J6/$M6*(AS6-AR6),$J6/$M6*($L6-MAX(AR6,$K6)))),K6)
Cell R6 shouldn't return any result because it is out of date range. This is where things get mixed up.
Note that from column AR to BC, it is all year end dates from 2020 to 2031 as shown below.
Is there a better way to tackle this sort of formula as I seem to get dragged into a long and unreliable way of doing this....
ANSWERAnswered 2022-Jan-24 at 22:32
Here single function(♣) that will create a series of pro-rata multipliers (of appropriate length) for any given start/end date:
EDIT: see end of soln for extended version per OP comment to original soln...
I'm on a Mac and I'm attempting to run my k6 script against
http://localhost:4200 (angular app) locally.
The angular app is running and I can access it via the browser and using
My k6 script has the base URL set to
http://localhost:4200. However, all requests are being made to
http://127.0.0.1:4200 instead which is denied by MacOS.
How do I force k6 to NOT rewrite
localhost to the loopback address?
Adding various outputs of
ANSWERAnswered 2022-Jan-21 at 06:45
There is no application listening on port 4200 for your IPv4 address
127.0.0.1. 127.0.0.1 is the IPv4 loopback address. When k6 makes a request to
localhost, this hostname resolves to the IPv4 127.0.0.1.
However, your application seems to be listening on port 4200 for your IPv6 address
::1. ::1 is the IPv6 loopback address.
curl resolves the hostname
localhost to its IPv6 address.
How are you binding your application to the port? Usually, when binding to all interfaces of a host, you'd use the special IP address
I see a potential solutions:
- Make your application bind to IPv4 and IPv6, usually done by binding to address
- Change your k6 script to connect to IPv6
--dns "policy=preferIPv6"or add
- Disable IPv6 in your OS. This is a drastic change and I wouldn't recommend it
- Change your hosts file to resolve localhost to the IPv4 address
I am running a load test with k6, which tests my service with 6 scenarios. I am running my service with docker-compose and I want to restart my service between each scenario. I couldn't find a built-in method for this so I added a function to restart the service and added some code to call that function at the start of each scenario ( I declared a counter for each scenario with initial value 0 and call the restart function only when the counter is 1). but the function is getting called per VU, not as I expected. Is there any solution for this?
Thanks in advance...
ANSWERAnswered 2021-Dec-21 at 19:09
It sounds like you are not executing the scenarios in parallel (as I would expect from k6 scenarios), but rather in sequence.
There isn't anything builtin in k6, but why not have a simple shell script which performs the following steps in order:
I installed k6 v0.35.0, go 1.17.3, xk6@latest, Prometheus 2.32.0-beta.0, xk6-output-prometheus-remote@latest, and try to run k6 script, but I got below error:
I want to know whether k6 open source can save test result in Prometheus?...
ANSWERAnswered 2021-Dec-05 at 10:50
You are trying to execute a command with syntax used in Linux/POSIX shells in Microsoft's PowerShell. PowerShell uses different syntax to set environment variables for commands.
To set an environment variable in PowerShell, you have to execute a separate command before running your actual command.
No vulnerabilities reported
k6 is written in Go, so it's just a single statically-linked executable and very easy to build and distribute. To build from source you need Git and Go (1.16 or newer). Follow these instructions:.
Run go install go.k6.io/k6 which will: git clone the repo and put the source in $GOPATH/src/go.k6.io/k6 build a k6 binary and put it in $GOPATH/bin
Make sure you have $GOPATH/bin in your PATH (or copy the k6 binary somewhere in your PATH), so you are able to run k6 from any location.
Tada, you can now run k6 using k6 run script.js
Beyond the init code and the required VU stage (i.e. the default function), which is code run for each VU, k6 also supports test-wide setup and teardown stages, like many other testing frameworks and tools. The setup and teardown functions, like the default function, need to be exported. But unlike the default function, setup and teardown are only called once for a test - setup() is called at the beginning of the test, after the init stage but before the VU stage (default function), and teardown() is called at the end of a test, after the last VU iteration (default function) has finished executing. This is also supported in the distributed cloud execution mode via k6 cloud.
Reuse Trending Solutions
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page