A k6 extension that provides a simple, thread-safe global counter. Counter is shared across all Virtual Users (VUs) in a K6 test.
import counter from 'k6/x/counter';
export default function () {
counter.increment();
console.log(`Counter value: ${counter.Get()}`);
}
go install go.k6.io/xk6/cmd/xk6@latest
xk6 build --with github.com/zagaris/xk6-counter@latest
./k6 run atomic.test.js