-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { open } from 'k6/experimental/fs' | ||
import csv from 'k6/experimental/csv' | ||
import { scenario } from 'k6/execution' | ||
|
||
export const options = { | ||
iterations: 10, | ||
} | ||
|
||
// Open the csv file, and parse it ahead of time. | ||
let file; | ||
let csvRecords; | ||
(async function () { | ||
file = await open('data.csv'); | ||
|
||
// The `csv.parse` function consumes the entire file at once, and returns | ||
// the parsed records as a SharedArray object. | ||
csvRecords = await csv.parse(file, {delimiter: ','}) | ||
})(); | ||
|
||
|
||
export default async function() { | ||
console.log(csvRecords[scenario.iterationInTest]) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { open } from 'k6/experimental/fs' | ||
import csv from 'k6/experimental/csv' | ||
|
||
export const options = { | ||
iterations: 10, | ||
} | ||
|
||
let file; | ||
let parser; | ||
(async function () { | ||
file = await open('data.csv'); | ||
parser = new csv.Parser(file); | ||
})(); | ||
|
||
export default async function() { | ||
const {done, value} = await parser.next(); | ||
if (done) { | ||
throw new Error("No more rows to read"); | ||
} | ||
|
||
console.log(value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
firstname,lastname,age | ||
fariha,ehlenfeldt,72 | ||
qudratullah,gillfillan,50 | ||
jeleah,rodina,41 | ||
thaisia,nowalk,99 | ||
joey-lynn,wilsford,75 | ||
tudur,granville,81 | ||
aytek,umber,56 | ||
aynoor,hisaw,30 | ||
fiadh-rose,iravani,31 | ||
annely,ooley,70 |