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

99
Visualizações
Chrome and Firefox JavaScript execution caching behavior

I am working on a web application that involves doing a some computation with JavaScript. In a benchmark test, I found Chrome is significantly faster than Firefox in term of execution time. When I run with the built in performance analysis tool in both browsers, I found that Firefox spent a lot of time on this function whereas Chrome does not.

// compute n choose k
function choose(n, k) {
  k = Math.min(n - k, k);
  let res = 1;
  for (let i = 1; i <= k; i++) {
    res *= n - k + i;
    res /= i;
  }
  return res;
}

Given that my application will invoke this function in the order of magnitude of 10^7 times each with n <= 40 and k <= 10 during the benchmark, I suspect that Chrome's JavaScript engine will cache the result of this function (since it's deterministic and has no side effect) whereas Firefox does not. However, I am not familiar enough with the internals of those 2 JavaScript engine to be sure. It's appreciated if someone can provide more detailed explanation.

In addition, how should I change my code or browser settings to make it run faster on Firefox?

about 4 years ago · Juan Pablo Isaza
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