Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bench): update bench deps, add teenytest, and update bench runner for node 12+ #165

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

davemo
Copy link

@davemo davemo commented Nov 25, 2021

I wanted to try out the benchmarks but hit an error as it seemed there was an expected behaviour using require.resolve in node v10 that no longer works in v12+.

The benchmark, when run with node index.js was throwing this error for both uvu and tape:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './bin.js' is not defined by "exports" in 
/Users/davidmosher/code/uvu/bench/node_modules/uvu/package.json

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './bin/tape' is not defined by "exports" in 
/Users/davidmosher/code/uvu/bench/node_modules/tape/package.json

This PR fixes that error by using absolute paths to ./node_modules, so that you don't have to rely on upstream test frameworks to expose their internals within package.exports, and updates the benchmark test framework dependencies, along with adding a benchmark for testdouble/teenytest.

Updated numbers I got running on Node 16 on a 2013 MBP w/ 16gb RAM:

~> "ava"       took   1.04s  (764 ms)
~> "jest"      took   1.63s  (333 ms)
~> "mocha"     took   269ms  (7   ms)
~> "tape"      took   138ms  ( n/a  )
~> "teenytest" took   133ms  ( n/a  )
~> "uvu"       took   96ms   (1.5 ms)

- node 12 and up start throwing ERR_PACKAGE_PATH_NOT_EXPORTED if the module includes an exports key that does not explicitly expose the imported path when accessed with require.resolve
- https://nodejs.org/docs/latest-v12.x/api/all.html#errors_err_package_path_not_exported
- this fix removes the require.resolve resolution in order to access the truly private executables for modules that dont all expose their internals in this way
Copy link

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that bench/index.js doesn't fun for me on Node 18, but does run with the changes included here, so whether or not you want to add teenytest, the changes to bench/index.js seem like a good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants