If you are using same algorithm then 2x difference Java vs JS is not something surprising, I would expect this.
How do you compute top 10? With built-in Array.search + slice(0,10) I get ~2500ms and if I use binary heap tree ( https://github.com/tjfontaine/node-binaryheap ) (push every element and pop if tree length > 10) running time is down to 950ms Also, try to benchmark your code after multiple runs as first run might use non-optimised code On Sunday, 3 August 2014 05:34:26 UTC+10, Juan Sebastian wrote: > > Hi All > > I'm Coding some trees in NodeJS > and after creating 1,000,000 elements and looping to get the top10 > elements > the process ends with these stats: > > TOP 10 Products by ID: > { Id: 31229, numSold: 99999741 } > { Id: 724109, numSold: 99999702 } > { Id: 228470, numSold: 99999663 } > { Id: 252501, numSold: 99999630 } > { Id: 764570, numSold: 99999462 } > { Id: 525615, numSold: 99999414 } > { Id: 789503, numSold: 99999379 } > { Id: 428851, numSold: 99999260 } > { Id: 533397, numSold: 99999244 } > { Id: 202426, numSold: 99999146 } > Max Quantity Item : id: 31229 Quantity: 99,999,741 > Min Quantity Item: id: 691832 Quantity: 76 > Process: 4547ms > > is there any way to improve the performance from the V8 side? > > I've tried the following line but makes no significant difference > ./node --max_executable_size=3048 --stack_size=102400 test.js > ./node --max_old_space_size=3048 --stack_size=102400 test.js > > I coded the same in Java and > by modifying the arguments to the JVM (increase the memory) > JRE Arguments -> -Xms1024m -Xmx2048m > the performance was significant faster: for 1,000,000 elements-> Time: > 1730 ms > > Any advice/trick will be welcomed > > Best Regards > > Juan S. > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/67c37c93-885c-4cd8-8a1b-52a2f79c8715%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.