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

Mitata benchmark #548

Merged
merged 16 commits into from
Feb 11, 2025
Merged

Conversation

andolivieri-nf
Copy link
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
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
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?

}

runSuites().catch(console.error)
if (fileURLToPath(import.meta.url) === process.argv[1]) runSuites().catch(console.error)
Copy link
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)

}

runSuites().catch(console.error)
if (import.meta.filename === process.argv[1]) runSuites().catch(console.error)
Copy link
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?

}

await saveLogs('auth0')
}

runSuites().catch(console.error)
runSuites()
Copy link
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!

${verifyBenchmark.map(printDetail).join('\n')}
`

await writeFile(new URL('README.md', import.meta.url), pageMarkdownContent, 'utf8')
Copy link
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?

[`${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
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
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
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.

[`${algorithm} - @node-rs/jsonwebtoken (sync)`]: function () {
nodeRsSignSync({ data: payload }, privateKey, { algorithm: Algorithm[algorithm.toUpperCase()] })
},
[`${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
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
6 checks passed
@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