Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

103
Vistas
Use worker threads to speed up array search (NodeJS)

Made a function that searches a specific string in a very very large array of strings using Levenshtein Distance. But it's too slow. Takes around 6000-10000ms to complete. How can I make it fast? I expected the function to end in less than 1000ms. Is it possible by using worker threads, cluster or anything else to run the loop in parallel so that I'll get the result in less than a second?

const leven = require('leven');
const veryLargeArray = ['foo bar foo', 'ajskdnasjkd', 'fooo fooo bar fooo', 'bar fooo', /*This array in my actual code has more than 900K strings*/];

function search(str, arr) {
      const results = [];
      for (const item of arr) {
        results.push({ item, distance: leven(str, arr[i]) });
      }
      return results;
}

search('hello', [...veryLargeArray]);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda