increment

package module
v0.0.0-...-a07c772 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 2 Imported by: 0

README

xk6-increment

This is a k6 extension using the xk6 system.

❗ This is a proof of concept, isn't supported by the k6 team, and may break in the future. USE AT YOUR OWN RISK!

This projects implements a singular local counter(name is bad) that goes up. It will return the current value before increasing it, and each VU will get a different value. Which means that it can be used to iterate over an array, where:

  1. only one element will be used by each VU
  2. the array doesn't need to be sharded between the VUs it will "dynamically" balance between them even if some elements take longer to process
This totally doesn't work in distributed manner, so if there are multiple k6 instances you will need a separate service (API endpoint) which to do it.

Predominantly because of the above this is very unlikely to ever get in k6 in it's current form, so please don't open issues :D.

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then, install xk6 and build your custom k6 binary with increment extension:

  1. Install xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/msaf1980/xk6-increment@latest

example

import counter from "k6/x/increment"
export default function() {
    console.log(increment.up(), __VU, __ITER)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Increment

type Increment struct {
	// contains filtered or unexported fields
}

func (*Increment) Next

func (c *Increment) Next() int64

type Module

type Module struct{}

func New

func New() *Module

func (*Module) XIncrement

func (m *Module) XIncrement(max int64) *Increment

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL