Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
Does converting the synchronous function to an asynchronous function that does no asynchronous job under the hood bring about a performance loss?

That is if I want to rewrite a function that is given below

  getDefaultNodes(){
    return this.defaultNodes;
  }
engine.js
-----------------------------
  const defaultNodes = engine.getDefaultNodes();
the place where its method is called.

as

  async getDefaultNodes(){
    return this.defaultNodes;
  }
engine.js
-----------------------------
  const defaultNodes = await engine.getDefaultNodes();
the place where its method is called.

Does this cause a performance issue? If yes, to what extent?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Does this bring about a performance loss?

Yes. There's some overhead in creating the promise, resolving it, waiting for it, breaking the code apart on the await, and scheduling continuations on the microtask queue. It also will prevent some possible optimisations (or at least make them much harder).

If yes, to what extent? Is it an issue?

It depends. Measure it if you care. It might not be significant, but still I'd argue that at least it is bad code.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda