chore: Add performance benchmark to diff-sequences
package
#7603
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Compare improved
diff-sequences
package to baselinediff
package.perf/index.js
fileperf/example.md
file which contains copied result of a run"scripts"
inpackage.json
filebenchmark
anddiff
asdevDependencies
Because allocating and freeing of temporary objects is the root of the performance problem, the tests call
global.gc()
before every test cycle, so make sure to run node with--expose-gc
option!Above 2000 items, the
benchmark
package can’t keep the relative mean error below its target of 1%For example, notice in next to last row of
example.md
that an outlier low0.0083
ratio corresponds to outlier high3.60%
baseline rme: an inaccurate high denominator causes low ratio.Your critique is always welcome and especially because perf benchmark is new for me :)
P.S. I added
/* eslint import/no-extraneous-dependencies: "off" */
because the rule demanded thatbenchmark
anddiff
becomedependencies
instead ofdevDependencies
Test plan
To achieve 1% relative mean error, run the benchmark:
I ran it with node 10.15.0 not via
yarn
in subdirectory:node --expose-gc perf/index.js
See most values of ratio are between
0.05
and0.15
The most relevant test for catastrophic performance problems is
insert 80%
that is, after every 2 expected items, insert 8 unexpected items: