victornpb / benchmark-html-parser-libraries

A Benchmark of javascript libraries for parsing HTML (CPU/RAM)
MIT License
6 stars 1 forks source link

Test setup instantiates a new parser for every file #2

Open daKmoR opened 3 years ago

daKmoR commented 3 years ago

I think many parsers are built so they can parse multiple html files one after another while using the same instance.

I assume you will get fastly different numbers if you rewrite this https://github.com/victornpb/benchmark-html-parser-libraries/blob/master/tests/sax.js

const sax = require("sax");

module.exports = function (html) {
    return new Promise((resolve, reject) => {
        const parser = sax.parser(false);

        parser.onend = resolve;
        parser.onerror = reject;
        parser.write(html);
        parser.close();
    });
};

to something like this

const sax = require("sax");
const parser = sax.parser(false);

module.exports = function (html) {
    return new Promise((resolve, reject) => {
        parser.onend = resolve;
        parser.onerror = reject;
        parser.write(html);
        parser.close();
    });
};
victornpb commented 3 years ago

You're right, i'm gonna change it!