Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9197445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:04:31+00:00 2026-06-17T22:04:31+00:00

I am reading about 3 million rows from a file and inserting them into

  • 0

I am reading about 3 million rows from a file and inserting them into STL maps. So, inside my while loop where I read each line from the file, I also print to console what row number it is through a simple cout statement. One of my friends recently pointed out that this makes code slower. I was wondering whether it is true and if it is why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:04:32+00:00Added an answer on June 17, 2026 at 10:04 pm

    As already mentioned, writing to the terminal is almost definitely going to be slower. Why?

    • depending on your OS, std::cout may use line buffering – which means each line may be sent to the terminal program separately. When you use std::endl rather than ‘\n’ it definitely flushes the buffer. Writing the data in smaller chunks means extra system calls and rendering efforts that slow things down significantly.

    • some operating systems / compilers are even slower – for example, Visual C++: https://connect.microsoft.com/VisualStudio/feedback/details/642876/std-wcout-is-ten-times-slower-than-wprintf-performance-bug-in-c-library

    • terminals displaying output need to make calls to wipe out existing screen content, render the fonts, update the scroll bar, copy the lines into the history/buffer. Especially when they get new content in small pieces, they can’t reliably guess how much longer they’d have to wait for some more and are likely to try to update the screen for the little bit they’ve received: that’s costly, and a reason excessive flushing or unbuffered output is slow.

      • Some terminals offer the option of “jump scrolling” which means if they find they’re say 10 pages behind they immediately render the last page and the earlier 9 pages of content never appear on the screen: that can be nice and fast. Still, “jump scrolling” is not always used or wanted, as it means output is never presented to the end users eyes: perhaps the program is meant to print a huge red error message in some case – with jump scrolling there wouldn’t even be a flicker of it to catch the user’s attention, but without jump scrolling you’d probably notice it.

      • when I worked for Bloomberg we had a constant stream of log file updates occupying several monitors – at times the displayed output would get several minutes behind; a switch from the default Solaris xterm to rxvt ensured it always kept pace

    • redirecting output to /dev/null is a good way to see how much your particular terminal is slowing things down

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While reading about exception, I will always come across checked exceptions and unchecked exceptions,
While reading about mcv3 I came across an attribute name called [ActionName] . It
I am inserting documents into MongoDB from a map in a MapReduce job. A
Reading about F# today and I'm not clear on one thing: From: http://msdn.microsoft.com/en-us/library/dd233200.aspx you
I have a very large excel file, it has about one milion rows and
Ok, so I'm reading a binary file into a char array I've allocated with
I have a big data set into MySQL (users, companies, contacts)? about 1 million
I'm reading a book about ASP.NET MVC 2, and when I read about how
ok. I was reading about cassandra and every article i read mentioned that writes
My project parse xml file from dblp , it about 1Gb to save in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.