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

275
Visualizações
Regexp affecting performance of nodejs app. How to replace improve Regexp in javascript?

I am developing an electron/nodejs app that uses some regexps, two of them are the following :

str=  str.replace(/\((.*?)\)/, "");
str= str.match(/\d+/g);

I am using these regexps inside a function that blocks my electron UI. I then tested the function and I found out that regexps are taking much time.

I researched this issue through SO but alas! JavaScript regexp performance. This did not help me.

Edit: I have thousands of strings to be tested by regexp. which create a very bad impact even blocks the UI of my electron app!

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

0

I have done a similar task on log files with hundreds of thousands of entries. Unfortunately Node & Electron are not the best choices for this type of task.

While maybe not ideal, the overall solution I was able to use was to create a small application in golang (albeit it could be any other more efficient language) which accepts a simple command line argument and then returns piped data.

After this I was able to use Node/Electron to spawn the child process and call the golang program and grab the response. I was able to reduce minutes of processing to seconds and still enjoy my wonderful Electron interface.

Sometimes a little creativity goes a long way. There is not a single language which is stellar in everything, sometimes it is best to pull strengths from each.

about 4 years ago · Juan Pablo Isaza Relatório

0

Unfortunately doing that kind of processing on thousands of strings is probably not likely to be too efficient regardless of what you do.

I don't have any experience with electron, but you might see if it's possible to use web workers to split up the work among multiple threads and get the heavy processing done faster. See Using Web Workers from MDN and the top answer to this SO post for some good info on web workers.

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