caniemail
Version:
HTML and CSS Feature Support for Email Clients from caniemail.com
26 lines • 1.17 kB
JavaScript
import { readFile } from 'node:fs/promises';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { performance } from 'node:perf_hooks';
import rehypeParse from 'rehype-parse';
import { unified } from 'unified';
import * as htmlparser from 'htmlparser2';
import * as parse5 from 'parse5';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
(async () => {
const html = await readFile(join(__dirname, '../test/fixtures/email.html'), 'utf8');
const unifiedStart = performance.now();
unified().use(rehypeParse, { fragment: false }).parse(html);
const unifiedEnd = performance.now();
const htmlparserStart = performance.now();
htmlparser.parseDocument(html);
const htmlparserEnd = performance.now();
const p5Start = performance.now();
parse5.parse(html);
const p5End = performance.now();
console.log(`Unified parser: ${(unifiedEnd - unifiedStart).toFixed(3)}ms`);
console.log(`HTMLParser2: ${(htmlparserEnd - htmlparserStart).toFixed(3)}ms`);
console.log(`parse54: ${(p5End - p5Start).toFixed(3)}ms`);
})();
//# sourceMappingURL=bench.js.map