Skip to content

Commit 7943760

Browse files
[feat] make scenario examples more general
- Simpler language - Less specific annotation of the code, making it easier to change later, and easier for users to copy, paste, and modify without incoherent comments.
1 parent bf8a62b commit 7943760

File tree

6 files changed

+56
-55
lines changed

6 files changed

+56
-55
lines changed

src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios/01 Executors/01 shared-iterations.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ number of total iterations, and the amount of iterations per VU is unimportant.
3636
If the **time to complete** a number of test iterations is your concern, this executor should perform best.
3737

3838
An example use case is for quick performance tests in the developement build cycle.
39-
As developers make changes, they might run the test against the local code to test for performance regressions. Thus the executor works well with a _shift-left_ policy, where emphasizes testing performance early in the development cycle when the cost of a fix is lowest.
39+
As developers make changes, they might run the test against the local code to test for performance regressions.
40+
Thus the executor works well with a _shift-left_ policy, where emphasizes testing performance early in the development cycle, when the cost of a fix is lowest.
4041

4142
## Example
4243

43-
In this example, we'll execute 200 total iterations shared by 10 VUs with a maximum duration of 30 seconds.
44+
The following example schedules 200 total iterations shared by 10 VUs with a maximum test duration of 30 seconds.
4445

4546
<CodeGroup labels={[ "shared-iters.js" ]} lineNumbers={[true]}>
4647

@@ -62,7 +63,7 @@ export const options = {
6263

6364
export default function () {
6465
http.get('https://test.k6.io/contacts.php');
65-
// We're injecting a processing pause for illustrative purposes only!
66+
// Injecting sleep
6667
// Sleep time is 500ms. Total iteration time is sleep + time to finish request.
6768
sleep(0.5);
6869
}
@@ -79,9 +80,8 @@ The following graph depicts the performance of the [example](#example) script:
7980
Based upon our test scenario inputs and results:
8081

8182
* Test is limited to a fixed number of 200 iterations of the `default` function;
82-
* the number of VUs is fixed to 10, and are initialized before the test begins;
83-
* each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
84-
* maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, `2 iters/s * 10 VUs`;
85-
* we then see that the maximum throughput is maintained for a larger portion of the test;
86-
* the 8 second test duration will be the shortest of all executor methods;
87-
* we know the distribution of iterations may be skewed; one VU may have performed 50 iterations, whereas another may have only performed 10.
83+
* The number of VUs is fixed to 10, and are initialized before the test begins;
84+
* Each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
85+
* Maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, `2 iters/s * 10 VUs`;
86+
* The maximum throughput is maintained for a larger portion of the test;
87+
* The distribution of iterations may be skewed: one VU may have performed 50 iterations, another only 10.

src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios/01 Executors/02 per-vu-iterations.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ partition between VUs.
2525

2626
## Example
2727

28-
In this example, we'll let 10 VUs execute 20 iterations _each_, for a total of 200 iterations, with
29-
a maximum duration of 30 seconds.
28+
The following example schedules 10 VUs to execute 20 iterations _each_.
29+
The test runs 200 total iterations and has a maximum duration of 30 seconds.
3030

3131
<CodeGroup labels={[ "per-vu-iters.js" ]} lineNumbers={[true]}>
3232

@@ -48,7 +48,7 @@ export const options = {
4848

4949
export default function () {
5050
http.get('https://test.k6.io/contacts.php');
51-
// We're injecting a processing pause for illustrative purposes only!
51+
// Injecting sleep
5252
// Sleep time is 500ms. Total iteration time is sleep + time to finish request.
5353
sleep(0.5);
5454
}
@@ -65,10 +65,10 @@ The following graph depicts the performance of the [example](#example) script:
6565
Based upon our test scenario inputs and results:
6666

6767
* The number of VUs is fixed at 10, and are initialized before the test begins;
68-
* total iterations are fixed at 20 iterations per VU, i.e. 200 iterations, `10 VUs * 20 iters each`;
69-
* each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
70-
* maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, `2 iters/s * 10 VUs`;
71-
* we then see that the maximum throughput is reached, but not maintained;
72-
* because distribution of iterations is even amongst VUs, a _fast_ VU may finish early and be idle for the remainder of the test, thereby lowering _efficiency_;
73-
* total duration of 9 seconds is slightly longer than [shared iterations](/using-k6/scenarios/executors/shared-iterations) due to lower efficiency;
74-
* overall test duration lasts as long as the _slowest_ VU takes to complete 20 requests.
68+
* Total iterations are fixed at 20 iterations per VU, i.e. 200 iterations, `10 VUs * 20 iters each`;
69+
* Each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
70+
* Maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, `2 iters/s * 10 VUs`;
71+
* The maximum throughput is reached, but not maintained;
72+
* Because the distribution of iterations is even among VUs, a _fast_ VU may finish early and be idle for the remainder of the test, thereby lowering _efficiency_;
73+
* Total duration of 9 seconds is slightly longer than [shared iterations](/using-k6/scenarios/executors/shared-iterations) due to lower efficiency;
74+
* Overall test duration lasts as long as the _slowest_ VU takes to complete 20 requests.

src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios/01 Executors/03 constant-vus.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Use this executor if you need a specific number of VUs to run for a certain amou
2323

2424
## Example
2525

26-
In this example, we'll run 10 VUs constantly for a duration 30 seconds.
26+
This examples schedules 10 VUs to run constantly for a duration 30 seconds.
2727

2828
<CodeGroup labels={[ "constant-vus.js" ]} lineNumbers={[true]}>
2929

@@ -44,8 +44,8 @@ export const options = {
4444

4545
export default function () {
4646
http.get('https://test.k6.io/contacts.php');
47-
// We're injecting a processing pause for illustrative purposes only!
48-
// Sleep time is 500ms. Total iteration time is sleep + time to finish request.
47+
// Injecting sleep
48+
// Total iteration time is sleep + time to finish request.
4949
sleep(0.5);
5050
}
5151
```
@@ -61,8 +61,8 @@ The following graph depicts the performance of the [example](#example) script:
6161
Based upon our test scenario inputs and results:
6262

6363
* The number of VUs is fixed at 10, and are initialized before the test begins;
64-
* overall test duration is fixed at the configured 30 second duration;
65-
* each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
66-
* maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, `2 iters/s * 10 VUs`;
67-
* we see that the maximum throughput is reached and maintained for the majority of the test;
68-
* approximately 600 iterations are therefore performed in total, `30 seconds * 20 iters/s`.
64+
* Overall test duration is fixed at the configured 30 second duration;
65+
* Each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
66+
* Maximum throughput (highest efficiency) is therefore expected to be ~20 iters/s, `2 iters/s * 10 VUs`;
67+
* We see that the maximum throughput is reached and maintained for the majority of the test;
68+
* Approximately 600 iterations are therefore performed in total, `30 seconds * 20 iters/s`.

src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios/01 Executors/04 ramping-vus.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ of time.
2525

2626
## Example
2727

28-
In this example, we'll run a two-stage test, ramping up from 0 to 10 VUs over 20 seconds, then down
28+
This example schedules a two-stage test, ramping up from 0 to 10 VUs over 20 seconds, then down
2929
to 0 VUs over 10 seconds.
3030

3131
<CodeGroup labels={[ "ramping-vus.js" ]} lineNumbers={[true]}>
@@ -51,16 +51,20 @@ export const options = {
5151

5252
export default function () {
5353
http.get('https://test.k6.io/contacts.php');
54-
// We're injecting a processing pause for illustrative purposes only!
54+
// Injecting sleep
5555
// Sleep time is 500ms. Total iteration time is sleep + time to finish request.
5656
sleep(0.5);
5757
}
5858
```
5959

6060
</CodeGroup>
6161

62-
> Note the setting of `gracefulRampDown` to 0 seconds, which could cause some iterations to be
63-
interrupted during the ramp down stage.
62+
<Blockquote mod="note" title="">
63+
64+
With [`gracefulRampDown`](/using-k6/scenarios/concepts/graceful-stop/#the-gracefulrampdown) set to 0 seconds, some iterations might be
65+
interrupted during the rampdown stage.
66+
67+
</Blockquote>
6468

6569
## Observations
6670

@@ -70,12 +74,12 @@ The following graph depicts the performance of the [example](#example) script:
7074

7175
Based upon our test scenario inputs and results:
7276

73-
* We've defined 2 stages for a total test duration of 30 seconds;
74-
* stage 1 ramps _up_ VUs linearly from the `startVUs` of 0 to the target of 10 over a 20 second duration;
75-
* from the 10 VUs at the end of stage 1, stage 2 then ramps _down_ VUs linearly to the target of 0 over a 10 second duration;
76-
* each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
77-
* as the number of VUs changes, the iteration rate directly correlates; each addition of a VU increases the rate by \~2 iters/s, whereas each subtraction of a VU reduces by \~2 iters/s;
78-
* our example performed ~300 iterations over the course of the test.
77+
* The configuration defines 2 stages for a total test duration of 30 seconds;
78+
* Stage 1 ramps _up_ VUs linearly from the `startVUs` of 0 to the target of 10 over a 20 second duration;
79+
* From the 10 VUs at the end of stage 1, stage 2 then ramps _down_ VUs linearly to the target of 0 over a 10 second duration;
80+
* Each _iteration_ of the `default` function is expected to be roughly 515ms, or ~2/s;
81+
* As the number of VUs changes, the iteration rate directly correlates; each addition of a VU increases the rate by about 2 iters/s, whereas each subtraction of a VU reduces by about 2 iters/s;
82+
* The example performed ~300 iterations over the course of the test.
7983

8084
## Get the stage index
8185

src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios/01 Executors/05 constant-arrival-rate.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ So it's unnecessary to use a `sleep()` function at the end of the VU code.
5151

5252
## Example
5353

54-
This example starts a constant rate of 30 iterations per second for 30 seconds, allowing k6 to dynamically schedule up to 50 VUs.
54+
This example schedules a constant rate of 30 iterations per second for 30 seconds.
55+
It allocates 50 VUs for k6 to dynamically use as needed.
5556

5657
<CodeGroup labels={[ "constant-arr-rate.js" ]} lineNumbers={[true]}>
5758

@@ -65,22 +66,18 @@ export const options = {
6566
contacts: {
6667
executor: 'constant-arrival-rate',
6768

68-
// Our test should last 30 seconds in total
69+
// How long the test lasts
6970
duration: '30s',
7071

71-
// It should start 30 iterations per `timeUnit`. Note that iterations starting points
72-
// will be evenly spread across the `timeUnit` period.
72+
// How many iterations per timeUnit
7373
rate: 30,
7474

75-
// It should start `rate` iterations per second
75+
// Start `rate` iterations per second
7676
timeUnit: '1s',
7777

78-
// It should preallocate 2 VUs before starting the test
79-
preAllocatedVUs: 2,
78+
// Pre-allocate VUs
79+
preAllocatedVUs: 50,
8080

81-
// It is allowed to spin up to 50 maximum VUs to sustain the defined
82-
// constant arrival rate.
83-
maxVUs: 50,
8481
},
8582
},
8683
};
@@ -103,7 +100,7 @@ Based upon our test scenario inputs and results:
103100

104101
* The desired rate of 30 iterations started every 1 second is achieved and maintained for the majority of the test.
105102
* The test scenario runs for the specified 30 second duration.
106-
* Having started with 2 VUs (as specified by the `preAllocatedVUs` option), k6 automatically adjusts the number of VUs to achieve the desired rate, up to the `maxVUs`; for our test, this ended up as 17 VUs.
103+
* Having started with 2 VUs (as specified by the `preAllocatedVUs` option), k6 automatically adjusts the number of VUs to achieve the desired rate, up to the allocated number. For this test, this ended up as 17 VUs.
107104
* Exactly 900 iterations are started in total, `30s * 30 iters/s`.
108105

109-
> As in our example, using too low of a `preAllocatedVUs` setting will reduce the test duration at the desired rate, as resources need to continually be allocated to achieve the rate.
106+
> Using too low of a `preAllocatedVUs` setting will reduce the test duration at the desired rate, as resources need to continually be allocated to achieve the rate.

src/data/markdown/translated-guides/en/02 Using k6/14 Scenarios/01 Executors/06 ramping-arrival-rate.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ It's unnecessary to use a `sleep()` function at the end of the VU code.
5151
## Example
5252

5353
This is an example of a four-stage test.
54-
It initially stays at the defined rate of starting 300 iterations per minute over a one minute period.
54+
55+
It starts at the defined `startRate`, 300 iterations per minute over a one minute period.
5556
After one minute, the iteration rate ramps to 600 iterations started per minute over the next two minutes, and stays at this rate for four more minutes.
5657
In the last two minutes, it ramps down to a target of 60 iterations per minute.
5758

@@ -68,7 +69,7 @@ export const options = {
6869
contacts: {
6970
executor: 'ramping-arrival-rate',
7071

71-
// Start at 300 iterations per `timeUnit`
72+
// Start iterations per `timeUnit`
7273
startRate: 300,
7374

7475
// Start `startRate` iterations per minute
@@ -109,14 +110,13 @@ The following graph depicts the performance of the [example](#example) script:
109110

110111
Based upon our test scenario inputs and results:
111112

112-
* We've defined 4 stages for a total test duration of 9 minutes.
113+
* The configuration defines 4 stages for a total test duration of 9 minutes.
113114
* Stage 1 maintains the `startRate` iteration rate at 300 iterations started per minute for 1 minute.
114115
* Stage 2 ramps _up_ the iteration rate linearly from the *stage 1* of 300 iterations started per minute, to the target of 600 iterations started per minute over a 2-minute duration.
115116
* Stage 3 maintains the *stage 2* iteration rate at 600 iterations started per minute over a 4-minute duration.
116117
* Stage 4 ramps _down_ the iteration rate linearly to the target rate of 60 iterations started per minute over the last two minutes duration.
117-
* Changes to the iteration rate are performed by k6, adjusting the number of VUs as necessary from `preAllocatedVUs` to a maximum of `maxVUs`.
118-
* The script waits for a period of time (defined by the `gracefulStop` option) for iterations to finish. It won't start new iterations during the `gracefulStop` period.
119-
* The script will run the `teardown()` function (if specified) before exiting.
118+
* Changes to the iteration rate are performed by k6, adjusting the number of VUs
119+
* The script waits for a period of time (defined by the `gracefulStop` option) for iterations to finish. It doesn't start new iterations during the `gracefulStop` period.
120120
* Our example performed, 4020 iterations over the course of the test.
121121

122122
## Get the stage index

0 commit comments

Comments
 (0)