MCPcopy
hub / github.com/adaltas/node-csv / main

Function main

packages/csv-parse/bench/async.iterator.js:87–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

85};
86
87const main = async function () {
88 const tests = [20000, 200000, 2000000, 20000000, 200000000].map((length) => ({
89 length: length,
90 target: path.join(os.tmpdir(), `data-${length}.csv`),
91 }));
92 const report = reporter();
93 await Promise.all(
94 tests.map(async function ({ length, target }) {
95 const time = process.hrtime();
96 await write(length, target);
97 const [seconds] = process.hrtime(time);
98 console.log(`File ${target} created in ${seconds} seconds`);
99 }),
100 );
101 await Promise.all(
102 tests.map(async function ({ length, target }) {
103 const hrtime = process.hrtime();
104 await read(length, target);
105 const [seconds, hrtime_nanoseconds] = process.hrtime(hrtime);
106 const nanoseconds = seconds * NS_PER_SEC + hrtime_nanoseconds;
107 const throughput = Math.round((length / nanoseconds) * NS_PER_SEC);
108 console.log(
109 "Benchmark time:",
110 `${nanoseconds} nanoseconds (${seconds} seconds)`,
111 );
112 console.log(
113 "Benchmark throughput:",
114 Math.round(throughput),
115 "records per second",
116 );
117 report(length, nanoseconds, throughput);
118 }),
119 );
120 await Promise.all(
121 tests.map(async function ({ target }) {
122 await dispose(target);
123 }),
124 );
125 const results = report();
126 print(results);
127};
128
129main();
130

Callers 1

async.iterator.jsFile · 0.70

Calls 5

reporterFunction · 0.85
writeFunction · 0.85
disposeFunction · 0.85
printFunction · 0.85
readFunction · 0.70

Tested by

no test coverage detected