Skip to content

Instantly share code, notes, and snippets.

@nikajordania
Last active May 11, 2025 15:24
Show Gist options
  • Save nikajordania/c211264baa216e1dd3bd89cff2878a41 to your computer and use it in GitHub Desktop.
Save nikajordania/c211264baa216e1dd3bd89cff2878a41 to your computer and use it in GitHub Desktop.
import {open} from 'k6/experimental/fs'
import csv from 'k6/experimental/csv'
import {scenario} from 'k6/execution'
import exec from "k6/execution";
export const options = {
executor: "shared-iterations",
vus: 10,
iterations: 200,
}
let file = await open('data.csv');
let csvRecords = await csv.parse(file, {delimiter: ',', asObjects: true});
export default async function () {
console.log(`VU: ${__VU} - ITER: ${__ITER}`);
let uniqueNumber = __VU * 100 + __ITER -100 ;
console.log(uniqueNumber);
console.log(exec.test.options.scenarios.default.vus + "asdsd"); // 10
let record = csvRecords[scenario.iterationInTest];
// The csvRecords a SharedArray. Each element is a record from the CSV file, represented as an array
// where each element is a field from the CSV record.
//
// Thus, `csvRecords[scenario.iterationInTest]` will give us the record for the current iteration.
console.log(record.user)
console.log(record.param)
//
// let uniqueNumber1 = __VU * 100 + __ITER;
// let user = data.users[uniqueNumber1];
// console.log(data.users[uniqueNumber1].username);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment