Skip to content

Mitata benchmark#548

Merged
andolivieri-nf merged 16 commits intonearform:masterfrom
andolivieri-nf:mitata_benchmark
Feb 11, 2025
Merged

Mitata benchmark#548
andolivieri-nf merged 16 commits intonearform:masterfrom
andolivieri-nf:mitata_benchmark

Conversation

@andolivieri-nf
Copy link
Copy Markdown
Contributor

@andolivieri-nf andolivieri-nf commented Feb 10, 2025

Closes #543

  • Update benchmark tests to use mitata library instead of cronometro
  • Move benchmarks to a separate BENCHMARKS.md file, add benchmark:update to generate it
  • Fix verify benchmark: bad PS512 token

@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. documentation Improvements or additions to documentation labels Feb 10, 2025
Comment thread README.md Outdated
║ EdDSA - fast-jwt (sync with cache) │ 10000 │ 202628.41 op/sec │ ± 3.12 % │ + 3080.69 % ║
╚═════════════════════════════════════╧═════════╧══════════════════╧═══════════╧═════════════════════════╝
```
See [BENCHMARKS.md](./benchmarks/BENCHMARKS.md)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why don't we name the file README so when you navigate to the folder it shows immediately?

Comment thread benchmarks/decode.mjs Outdated
}

runSuites().catch(console.error)
if (fileURLToPath(import.meta.url) === process.argv[1]) runSuites().catch(console.error)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you're probably looking for import.meta.filename (please beware of compatibility though)

Comment thread benchmarks/sign.mjs Outdated
}

runSuites().catch(console.error)
if (import.meta.filename === process.argv[1]) runSuites().catch(console.error)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if we keep .catch-ing errors in this way, are we not potentially hiding errors and therefore risk that they go unnoticed as they did already?

Comment thread benchmarks/auth0.mjs Outdated
}

runSuites().catch(console.error)
runSuites()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: let's take this one step further. top level await has been here for a long time, let's use it!

Comment thread benchmarks/update_benchmarks.mjs Outdated
${verifyBenchmark.map(printDetail).join('\n')}
`

await writeFile(new URL('README.md', import.meta.url), pageMarkdownContent, 'utf8')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we use dirname here?

Comment thread benchmarks/utils.mjs
[`${algorithm} - jsonwebtoken (async)`]: function (done) {
jsonwebtokenSign(payload, privateKey, { algorithm, noTimestamp: true }, done)
[`${algorithm} - jsonwebtoken (async)`]: async function () {
return new Promise(resolve => jsonwebtokenSign(payload, privateKey, { algorithm, noTimestamp: true }, resolve))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

think about what you're doing here and if this change really makes sense :) this was necessary because you were dealing with callbacks. now you have promises, so none of this is necessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is true for other node-rs / fast-jwt which have promise API indeed, and do not need the new Promise(etc..) ; but in this specific case you highlighted of jsonwebtoken lib, I only see the sign function overloads with/without callback. what are you suggesting?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

when the callback based version is needed, will need to stick to the existing pattenr, but it looks to me like there are no more occurrences of that pattern.

Comment thread benchmarks/utils.mjs
},
[`${algorithm} - @node-rs/jsonwebtoken (async)`]: function (done) {
nodeRsSign({ data: payload }, privateKey, { algorithm: Algorithm[algorithm.toUpperCase()] }).then(() => done())
[`${algorithm} - @node-rs/jsonwebtoken (async)`]: async function () {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

strictly speaking, async is not required either unless something's awaited in the body of the function, but ok it's a small detail

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 11, 2025
@andolivieri-nf andolivieri-nf merged commit ce5b923 into nearform:master Feb 11, 2025
@andolivieri-nf andolivieri-nf deleted the mitata_benchmark branch February 11, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch benchmarking tool from cronometro to mitata

2 participants