File tree 3 files changed +9
-24
lines changed
3 files changed +9
-24
lines changed Original file line number Diff line number Diff line change @@ -7,16 +7,10 @@ export const options = {
7
7
}
8
8
9
9
// Open the csv file, and parse it ahead of time.
10
- let file ;
11
- let csvRecords ;
12
- ( async function ( ) {
13
- file = await open ( 'data.csv' ) ;
14
-
15
- // The `csv.parse` function consumes the entire file at once, and returns
16
- // the parsed records as a SharedArray object.
17
- csvRecords = await csv . parse ( file , { delimiter : ',' } )
18
- } ) ( ) ;
19
-
10
+ const file = await open ( 'data.csv' ) ;
11
+ // The `csv.parse` function consumes the entire file at once, and returns
12
+ // the parsed records as a SharedArray object.
13
+ const csvRecords = await csv . parse ( file , { delimiter : ',' } )
20
14
21
15
export default async function ( ) {
22
16
// The csvRecords a SharedArray. Each element is a record from the CSV file, represented as an array
Original file line number Diff line number Diff line change @@ -5,20 +5,16 @@ export const options = {
5
5
iterations : 10 ,
6
6
}
7
7
8
- let file ;
9
- let parser ;
10
- ( async function ( ) {
11
- file = await open ( 'data.csv' ) ;
12
- parser = new csv . Parser ( file ) ;
13
- } ) ( ) ;
8
+ const file = await open ( 'data.csv' ) ; ;
9
+ const parser = new csv . Parser ( file ) ; ;
14
10
15
11
export default async function ( ) {
16
12
// The parser `next` method attempts to read the next row from the CSV file.
17
13
//
18
14
// It returns an iterator-like object with a `done` property that indicates whether
19
15
// there are more rows to read, and a `value` property that contains the row fields
20
16
// as an array.
21
- const { done, value} = await parser . next ( ) ;
17
+ const { done, value } = await parser . next ( ) ;
22
18
if ( done ) {
23
19
throw new Error ( "No more rows to read" ) ;
24
20
}
Original file line number Diff line number Diff line change @@ -5,16 +5,11 @@ export const options = {
5
5
iterations : 1000 ,
6
6
} ;
7
7
8
- // k6 doesn't support async in the init context. We use a top-level async function for `await`.
9
- //
10
8
// Each Virtual User gets its own `file` copy.
11
9
// So, operations like `seek` or `read` won't impact other VUs.
12
- let file ;
13
- ( async function ( ) {
14
- file = await open ( "bonjour.txt" ) ;
15
- } ) ( ) ;
10
+ const file = await open ( "bonjour.txt" ) ;
16
11
17
- export default async function ( ) {
12
+ export default async function ( ) {
18
13
// About information about the file
19
14
const fileinfo = await file . stat ( ) ;
20
15
if ( fileinfo . name != "bonjour.txt" ) {
You can’t perform that action at this time.
0 commit comments