Skip to content

Commit

Permalink
perf(parser-adapter-yaml-1-2): analyze performance profile
Browse files Browse the repository at this point in the history
Parsing stage result: 4.74 ops/sec ±0.72% (623 runs sampled)
Lexical Analysis result: 653 ops/sec ±3.40% (670 runs sampled)

Parsing stage on medium size documents takes
on average: 210,970464135 ms
Lexical analysis phase on medium size documents takes
on average: 1,639344262 ms

Observation:

Lexical analysis phase takes less than 1% of entire Parsing stage. This
means that we did good in choosing very fast underlying parser (TreeSitter)
for Lexical Analysis but we have huge opportunity to make
Syntactic Analysis (second phase of Parsing stage) faster by analyzing
TreeSitter CST directly into ApiDOM. Estimates performance gains are
within 250% - 300%. What we currently do is following transformation CST
-> YAML AST -> ApiDOM which require two full traversal passes.

Closes #408"
  • Loading branch information
char0n committed May 19, 2021
1 parent d7fe263 commit 89c8959
Show file tree
Hide file tree
Showing 5 changed files with 747 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apidom/packages/apidom-parser-adapter-yaml-1-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"lint": "eslint ./",
"lint:fix": "eslint ./ --fix",
"clean": "rimraf ./es ./cjs ./dist",
"test": "cross-env BABEL_ENV=cjs mocha"
"test": "cross-env BABEL_ENV=cjs mocha",
"perf": "cross-env BABEL_ENV=cjs node ./test/perf/index.js",
"perf:parsing": "cross-env BABEL_ENV=cjs node ./test/perf/parsing.js",
"perf:lexical-analysis": "cross-env BABEL_ENV=cjs node ./test/perf/lexical-analysis.js"
},
"author": "Vladimir Gorej",
"license": "Apache-2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"@typescript-eslint/no-var-requires": 0
}
}
21 changes: 21 additions & 0 deletions apidom/packages/apidom-parser-adapter-yaml-1-2/test/perf/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require('@babel/register')({ extensions: ['.js', '.ts'], rootMode: 'upward' });

const Benchmark = require('benchmark');

const parsingSyntacticAnalysisDirectBench = require('./parsing-syntactic-analysis-direct');
const parsingSyntacticAnalysisIndirectBench = require('./parsing-syntactic-analysis-indirect');

const suite = new Benchmark.Suite();

suite
.add(parsingSyntacticAnalysisDirectBench)
.add(parsingSyntacticAnalysisIndirectBench)
// add listeners
.on('cycle', function (event) {
console.info(String(event.target));
})
.on('complete', function () {
console.info('\nAll benchmarks have completed');
})
// run
.run();
Loading

0 comments on commit 89c8959

Please sign in to comment.