Giter Club home page Giter Club logo

file-read-challenge's People

Contributors

paigen11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

file-read-challenge's Issues

readFileEventStream.js running out of memory

Hey @paigen11

Thank you for sharing your code from your itnext post

I just tried it on my pc (window 10, node v8.12.0) but neither readFileStream or readFileEventStream were able to process the whole itcont.txt (3,49Go)

image
image

How did you execute your test? Have you any clues about why event-stream did worked for me?

Unnecessary loops in the close event

First of all, thank you for your post, it was quite good.

For streaming, in every rl.on('line', call you already have the current line, and you are extracting firstNames and formattedTimestamp already.

But rl.on('close' call you are again running loop over firstNames dateDonationCount arrays which is unnecessary.

On your rl.on('line' event you can calculate those values and then you can remove the unnecessary loops in the close event. That way your measurement will be way lower than the previous one.

Just check this out.

readFileStream.js

if (firstHalfOfName.includes(' ') && firstHalfOfName !== ' ') {
	firstName = firstHalfOfName.split(' ')[0];
	firstName.trim();
	firstNames.push(firstName);      
        // make your calculation here, no need to loop over firstNames again
	dupeNames[firstName] = (dupeNames[firstName] || 0) + 1;
} else {
	firstNames.push(firstHalfOfName);
	dupeNames[firstHalfOfName] = (dupeNames[firstHalfOfName] || 0) + 1;
}

[....]

dateDonationCount.push(formattedTimestamp);
// here, eliminate the dateDonationCount.forEach loop in the close event
dateDonations[formattedTimestamp] = (dateDonations[formattedTimestamp] || 0) + 1;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.