Skip to content

Commit

Permalink
chore: add make-synchronized to benchmark test
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 21, 2024
1 parent 69b8dcd commit efa6e3d
Show file tree
Hide file tree
Showing 6 changed files with 12,530 additions and 16,757 deletions.
1 change: 1 addition & 0 deletions benchmarks/benchmark.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ console.table(
synckit: perfCase('synckit'),
syncThreads: perfCase('sync-threads'),
deasync: perfCase('deasync'),
makeSynchronized: perfCase('make-synchronized'),
native: perfCase('native'),
}),
)
7 changes: 4 additions & 3 deletions benchmarks/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const __filename = fileURLToPath(import.meta.url)
const perfCase = async name => {
const loadStartTime = performance.now()

const syncFn =
// eslint-disable-next-line unicorn/no-await-expression-member
(await import(`./${name}.${name === 'synckit' ? 'js' : 'cjs'}`)).default
const { default: syncFn } = await import(
`./${name}.${name === 'synckit' || name === 'make-synchronized' ? 'js' : 'cjs'}`
)

const loadTime = performance.now() - loadStartTime

Expand Down Expand Up @@ -96,6 +96,7 @@ console.table(
synckit: await perfCase('synckit'),
syncThreads: await perfCase('sync-threads'),
deasync: await perfCase('deasync'),
makeSynchronized: await perfCase('make-synchronized'),
native: await perfCase('native'),
}),
)
6 changes: 6 additions & 0 deletions benchmarks/make-synchronized.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { makeSynchronized } = require('make-synchronized')

/** @type {() => string} */
const syncFn = makeSynchronized(require.resolve('./native.cjs'))

module.exports = syncFn
11 changes: 11 additions & 0 deletions benchmarks/make-synchronized.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { makeSynchronized } from 'make-synchronized'

/** @type {() => string} */
const syncFn = makeSynchronized(new URL('native.cjs', import.meta.url))

/** @type {() => string} */
// More reasonable test?
// const synchronizeOnFly = filename =>
// makeSynchronized('node:fs/promises').readFile(filename, 'utf8')

export default syncFn
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"execa": "^8.0.1",
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"make-synchronized": "^0.0.3",
"node-gyp": "^10.0.1",
"patch-package": "^8.0.0",
"prettier": "^3.1.1",
Expand Down
Loading

0 comments on commit efa6e3d

Please sign in to comment.