Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test setup instantiates a new parser for every file #2

Open
daKmoR opened this issue Jan 18, 2021 · 1 comment
Open

Test setup instantiates a new parser for every file #2

daKmoR opened this issue Jan 18, 2021 · 1 comment

Comments

@daKmoR
Copy link

daKmoR commented Jan 18, 2021

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants