nitro
nitro copied to clipboard
perf: Cache `global.Promise` for faster Promise creations
Benchmarks
10.000 calls to getValueFromJSCallbackAndWait:
const start = performance.now()
let promises: Promise<number>[] = []
for (let i = 0; i < ITERATIONS; i++) {
promises.push(
HybridTestObjectSwiftKotlin.getValueFromJSCallbackAndWait(() =>
Math.random()
)
)
}
await Promise.all(promises)
const end = performance.now()
const nitroTime = end - start
- Before (main): ~160ms
- After (main): ~160ms
turns out this does not increase performance at all.
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
| Project | Deployment | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| nitro-docs | Sep 9, 2025 2:06pm |
@ChristopherGabba I can reproduce the error here:
- ❌ Test "JS Promise<void> can be awaited on native side" failed! Error: Expected test to not throw any errors, but an error was thrown! Error: Error: Timeouted: Promise<void> was destroyed!
nvm, it now works fine again. I broke it before, and now reverted my mistake in https://github.com/mrousavy/nitro/pull/866/commits/afab186105a3937cd548989d76818aacd66205d2.