Last active
November 21, 2024 18:54
-
-
Save llimllib/00a0ca860807b369b7196e32815b0a08 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env node | |
const { readFileSync } = require('node:fs'); | |
const { tags, mdast } = require('./dist/main.node.js'); | |
async function main() { | |
const { visit } = await import('unist-util-visit'); | |
// we actually fail to parse our own README? | |
// const data = readFileSync('README.md'); | |
const data = readFileSync('test.md').toString(); | |
// The tags function was added in v7.0.1; so for versions that don't have it, | |
// use the function that gitto had been using | |
if (tags) { | |
tags(data); | |
} else { | |
const ts = new Set(); | |
visit(mdast(data), 'reusable-content', node => { | |
// @ts-expect-error `tag` is here | |
ts.add(node.tag); | |
}); | |
Array.from(ts); | |
} | |
} | |
main().then(console.log('done')); |
This file contains 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
$ hyperfine "node test-7.7.1.js" "node test-7.8.0.js" "node test-7.9.0.js" "node test-7.10.0.js" "node test-main.js" | |
Benchmark 1: node test-7.7.1.js | |
Time (mean ± σ): 303.4 ms ± 1.9 ms [User: 313.1 ms, System: 11.9 ms] | |
Range (min … max): 301.6 ms … 307.9 ms 10 runs | |
Benchmark 2: node test-7.8.0.js | |
Time (mean ± σ): 358.0 ms ± 3.0 ms [User: 366.9 ms, System: 15.7 ms] | |
Range (min … max): 354.7 ms … 363.5 ms 10 runs | |
Benchmark 3: node test-7.9.0.js | |
Time (mean ± σ): 358.1 ms ± 2.6 ms [User: 367.0 ms, System: 15.9 ms] | |
Range (min … max): 354.2 ms … 363.4 ms 10 runs | |
Benchmark 4: node test-7.10.0.js | |
Time (mean ± σ): 358.6 ms ± 2.9 ms [User: 367.4 ms, System: 15.8 ms] | |
Range (min … max): 356.0 ms … 365.2 ms 10 runs | |
Benchmark 5: node test-main.js | |
Time (mean ± σ): 357.7 ms ± 1.9 ms [User: 367.1 ms, System: 15.9 ms] | |
Range (min … max): 355.6 ms … 362.1 ms 10 runs | |
Summary | |
node test-7.7.1.js ran | |
1.18 ± 0.01 times faster than node test-main.js | |
1.18 ± 0.01 times faster than node test-7.8.0.js | |
1.18 ± 0.01 times faster than node test-7.9.0.js | |
1.18 ± 0.01 times faster than node test-7.10.0.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment