File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
extensions/ql-vscode/test/benchmarks Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { readFile } from "fs-extra";
22import { readJsonlFile , readJsonlFile2 } from "../../src/common/jsonl-reader" ;
33import { performance } from "perf_hooks" ;
44import { join } from "path" ;
5+ import { createReadStream } from "fs" ;
6+ import { createInterface } from "readline" ;
57
68/** An "obviously correct" implementation to test against. */
79async function readJsonlReferenceImpl < T > (
@@ -19,6 +21,18 @@ async function readJsonlReferenceImpl<T>(
1921 }
2022}
2123
24+ async function justReadline (
25+ path : string ,
26+ handler : ( value : unknown ) => Promise < void > ,
27+ ) {
28+ const stream = createReadStream ( path , "utf8" ) ;
29+ const rl = createInterface ( stream ) ;
30+
31+ for await ( const line of rl ) {
32+ await handler ( line ) ;
33+ }
34+ }
35+
2236type ParserFn = (
2337 text : string ,
2438 callback : ( v : unknown ) => Promise < void > ,
@@ -28,6 +42,7 @@ const parsers: Record<string, ParserFn> = {
2842 readJsonlReferenceImpl,
2943 readJsonlFile,
3044 readJsonlFile2,
45+ justReadline,
3146} ;
3247
3348async function main ( ) {
You can’t perform that action at this time.
0 commit comments