toml-node icon indicating copy to clipboard operation
toml-node copied to clipboard

add benchmarks for issue #39

Open felix9 opened this issue 6 years ago • 0 comments

I decided to systematically benchmark various parsers on equivalent input. Here are some results, running on my laptop.

Empty or almost-empty file. json is the native JSON.parse, and it will almost always win. It's basically an upper bound on performance.

parse empty with ini           x 3,117,553 ops/sec ±0.83% (81 runs sampled)
parse empty with js-yaml       x 2,873,395 ops/sec ±1.33% (89 runs sampled)
parse empty with js-yaml(json) x 2,877,457 ops/sec ±0.91% (90 runs sampled)
parse empty with json          x 3,471,484 ops/sec ±0.95% (89 runs sampled)
parse empty with toml-j0.4     x 111,698 ops/sec ±0.84% (91 runs sampled)
parse empty with toml-node     x 140,756 ops/sec ±1.96% (89 runs sampled)
parse empty with yaml          x 580,454 ops/sec ±0.58% (91 runs sampled)
parse empty with yamljs        x 558,640 ops/sec ±0.90% (89 runs sampled)

Small hello-world file.

parse hello with ini           x 218,876 ops/sec ±1.03% (89 runs sampled)
parse hello with js-yaml       x 421,704 ops/sec ±1.10% (88 runs sampled)
parse hello with js-yaml(json) x 499,956 ops/sec ±0.80% (86 runs sampled)
parse hello with json          x 1,407,042 ops/sec ±0.83% (90 runs sampled)
parse hello with toml-j0.4     x 61,319 ops/sec ±0.82% (87 runs sampled)
parse hello with toml-node     x 34,552 ops/sec ±2.11% (87 runs sampled)
parse hello with yaml          x 171,860 ops/sec ±0.85% (94 runs sampled)
parse hello with yamljs        x 87,918 ops/sec ±1.31% (86 runs sampled)

Real cargo.toml from the Rust Cargo project (with minor changes).

parse cargo with js-yaml       x 9,848 ops/sec ±2.25% (85 runs sampled)
parse cargo with js-yaml(json) x 12,445 ops/sec ±0.90% (91 runs sampled)
parse cargo with json          x 64,939 ops/sec ±0.80% (88 runs sampled)
parse cargo with toml-j0.4     x 2,833 ops/sec ±1.87% (84 runs sampled)
parse cargo with toml-node     x 170 ops/sec ±1.07% (80 runs sampled)
parse cargo with yamljs        x 1,673 ops/sec ±4.90% (85 runs sampled)

toml-node is noticeably slower, and for cargo.toml most of the cost seems to be in the parser.

felix9 avatar Sep 02 '17 02:09 felix9