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 8452469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:30:28+00:00 2026-06-10T11:30:28+00:00

I have a C++ program where I do various experiments and during these experiments

  • 0

I have a C++ program where I do various experiments and during these experiments I output some values to a file using ofstream. The structure is basically:

 Start timer

 output to a file using ofstream (the output is, at most, a few words)

 do some experimental work

 Stop timer

My question, which is a bit broad, is can I ignore the time that the ofstream takes or it’s not something negligible ? or I guess it depends ?

  • 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-10T11:30:30+00:00Added an answer on June 10, 2026 at 11:30 am

    First of all, from your pseudo code, you could just start the timer after the file output 🙂 But I’m guessing it’s not like that in the real app.

    Beyond that, it’s obviously a matter of “it depends”. If you aren’t outputting all that much, and the code you’re interested in runs for minutes, then the output obviously won’t make much of a difference. If, on the other hand, you are trying to catch runtimes measured in microseconds, you’ll probably be mostly measuring the ofstream.

    You could try doing various magics, like running the actual output on a thread, or just adding your messages to a previously allocated char array and outputting that at the end. However, everything incurs some runtime penalty; nothing is ever free.

    Since you’re not interested in measuring the actual output time, you could compile a version without the output to do measurements, and a version with the output to debug the code. EDIT: or make that a runtime option. Nothing is ever free, but an “if (OutputEnabled)” is pretty close to “free” 🙂

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

Sidebar

Related Questions

I have a program which is able to retrieve various registry values using C#
Basically, I want to have my program retrieve various variables from the hard drive
I have a program that search some elements and show these on a GoogleMap.
I have a Python program that uses psutil to run some various twistd ...
I have a program that gets a JSON from the server using getJSON and
i have application with client-server architecture. client (C program): generate various DER encoded data
I have a wxPython program which reads from different datasets, performs various types of
I'm new to using WPF. I have the following program I want to create:
I have a wpf program in c# that has a combobox with various colors
I have written a program which analyzes a project's source code and reports various

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.