Skip to content

Using readline to optimize performance #3

@cweijan

Description

@cweijan

I tried ndjson to improve performance, but using this library is slower than JSON.parse(arrayString), I changed to readline to improve the speed, consider code like the following:

const readline = require('readline');
const fileStream = fs.createReadStream('data.txt');
const rl = readline.createInterface({
    input: fileStream,
    crlfDelay: Infinity
});
for await (const line of rl) {
    JSON.parse(line)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions