Skip to content

Commit

Permalink
fix: improve parser performance
Browse files Browse the repository at this point in the history
a lot of degradation occurred in the last few commits
  • Loading branch information
cyyynthia committed May 17, 2023
1 parent 5b2c866 commit 007ce4f
Show file tree
Hide file tree
Showing 11 changed files with 286 additions and 265 deletions.
5 changes: 5 additions & 0 deletions bench/parseLargeMixed.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { parse as smolTomlParse } from '../src/index.js'
import { parse as iarnaTomlParse } from '@iarna/toml'
import { parse as ltdJTomlParse } from '@ltd/j-toml'
import fastTomlParse from 'fast-toml'
import { decode as tomlNodejsParse } from 'toml-nodejs'

let toml = await readFile(new URL('./testfiles/5mb-mixed.toml', import.meta.url), 'utf8')

Expand All @@ -51,3 +52,7 @@ bench('@ltd/j-toml', () => {
bench('fast-toml', () => {
fastTomlParse(toml)
})

bench('toml-nodejs', () => {
tomlNodejsParse(toml)
})
5 changes: 5 additions & 0 deletions bench/parseSpecExample.bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { parse as smolTomlParse } from '../src/index.js'
import { parse as iarnaTomlParse } from '@iarna/toml'
import { parse as ltdJTomlParse } from '@ltd/j-toml'
import fastTomlParse from 'fast-toml'
import { decode as tomlNodejsParse } from 'toml-nodejs'

let toml = await readFile(new URL('./testfiles/toml-spec-example.toml', import.meta.url), 'utf8')

Expand All @@ -50,3 +51,7 @@ bench('@ltd/j-toml', () => {
bench('fast-toml', () => {
fastTomlParse(toml)
})

bench('toml-nodejs', () => {
tomlNodejsParse(toml)
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"type": "module",
"engines": {
"node": ">= 18",
"pnpm": ">= 7.24"
"pnpm": ">= 8"
},
"scripts": {
"build": "tsc",
Expand All @@ -29,6 +29,7 @@
"@types/node": "^20.1.0",
"@vitest/ui": "^0.31.0",
"fast-toml": "^0.5.4",
"toml-nodejs": "^0.3.0",
"typescript": "^5.0.4",
"vitest": "^0.31.0"
},
Expand Down
Loading

0 comments on commit 007ce4f

Please sign in to comment.