Created
August 14, 2024 15:28
-
-
Save llimllib/4b87fd4042359b4812350038562dba03 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Save test.mjs in the root of the repository, and run it as `node test.mjs` | |
import {fromMarkdown} from 'mdast-util-from-markdown' | |
import { | |
gfmAutolinkLiteralFromMarkdown, | |
gfmAutolinkLiteralToMarkdown | |
} from './lib/index.js' | |
const hundredA = 'a'.repeat(100) | |
const fileWithBreaks = `${hundredA}\n`.repeat(800) | |
const fileWithoutBreaks = `${hundredA}`.repeat(800) | |
// On my computer: parsing a file with breaks: 32.809ms | |
console.time('parsing a file with breaks') | |
fromMarkdown(fileWithBreaks, { | |
extensions: [], | |
mdastExtensions: [gfmAutolinkLiteralFromMarkdown()] | |
}) | |
console.timeEnd('parsing a file with breaks') | |
// On my computer: parsing a file without breaks: 10.127s | |
console.time('parsing a file without breaks') | |
fromMarkdown(fileWithoutBreaks, { | |
extensions: [], | |
mdastExtensions: [gfmAutolinkLiteralFromMarkdown()] | |
}) | |
console.timeEnd('parsing a file without breaks') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment