C
C
crdrads2019-01-29 21:45:29
JavaScript
crdrads, 2019-01-29 21:45:29

After rewriting from promises to asinks, did the time increase by x2?

There is a heavy operation for image resizing, optimization, envelope. In its current form on promises, the operation took 30 seconds. I tried to rewrite the aveites on async - the time doubled.
This is fine? Of course, I understand that this may be my crooked code, although there is nothing special there, for the performance to drop by half)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dima Pautov, 2019-01-29
@crdrads

Vryatli. Rather, your code, as you put it, is a curve. I will give a short example

const data1 = await promise1();
const data2 = await promise1();
//....

against
Promise.all([
  promise1(),
  promise1()
])
.then(() => {
  //....
})

which will be faster, provided that both queries do not depend on each other?
in the 1st variant, the requests will be executed sequentially, each will wait for the previous one;
in the 2nd variant, the requests will be executed in parallel.
That's the difference in performance. It's not about methods, it's about usage. Chances are you're doing exactly the same thing somewhere.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question