vitaly-t
vitaly-t

Reputation: 25930

Promise outperforms direct calculation?

I have been doing some benchmarks on a promise extension that I wrote, and I have stumbled upon some results that I cannot fathom: I'm getting consistently faster performance on a promise-based sequence calculation than doing the same directly, without promises.

Here's the test description: Linked and Detached Sequencing (I thought it would be perhaps too much reposting all that here).

Is there any special consideration within NodeJS that under increased load changes the way the engine works, so resolving promises during a heavy sequence calculation may result in increased performance? This is just my best guess for now, though perhaps a dumb one, I'm really scratching my head over this.

Upvotes: 3

Views: 87

Answers (1)

vitaly-t
vitaly-t

Reputation: 25930

The results were skewed due to an illusive mistake in the direct computation benchmark. After correcting the error the performance now does add up, being exactly what was expected.

So no, there is no magic in NodeJS engine, and Promise cannot perform faster than the normal direct calculation.

Upvotes: 2

Related Questions