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

  • Home
  • SEARCH
  • 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 8851433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:09:16+00:00 2026-06-14T13:09:16+00:00

I have a very specific question that I need answered for a very specific

  • 0

I have a very specific question that I need answered for a very specific performance test. I will simplify the code, to make it easier understandable.

I do many calculations (a few ten million), all done in loops that are themselves not too long and I need the total calculation time. However, all the calculations are not done directly one after another and some extra code “comes inbetween” every loop.

What I need, is quite exactly the total time of all loops (including declaring and initializing i, incrementing it, and comparison with 100 in exmaple). To measure the time I start a Stopwatch directly before every loop and stop it directly after the loop. But do those two actions need some time that might be relevant?

Example:

Stopwatch sw = new Stopwatch();

sw.Start();
//how long does it now take until for loop is reached?
for(int i = 0; i < 100; i++)
{
    //some calculations
}
//how much time does it take to stop sw?
sw.Stop();

Of course it wouldn’t really matter if all the loops were done directly one after another, I could just start at the beginning of the first loop and stop at the end of the last one, but that is not possible here.

I know the question is very specific, but I hope someone can help me here, as a significant time coming from around fifty million loops, could in a way affect my results.

  • 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-14T13:09:17+00:00Added an answer on June 14, 2026 at 1:09 pm

    Well, you could try this and check it on your own, on my (lousy performing ) computer it’s about 0.0006 milliseconds for the first execution and 0.0001 milliseconds for next executions. Try it yourself:

    Stopwatch sw = new Stopwatch();
    sw.Start();
    sw.Stop();
    TimeSpan ts = TimeSpan.FromTicks(sw.ElapsedTicks);
    string elapsed = ts.TotalMilliseconds.ToString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very specific case that I need to debug. I need to
The problem that I have is somehow very specific. I have to implement a
I have a particular application that needs to calculate something very specific, and while
I am very much a beginner to rails and I have a specific need
This question might seem very specific but I am in need of some ideas
this is a very specific question, but i also have very specific details on
the title might be too generic, but I have a very specific question about
This question is kind of general and not very specific. We have a java
I have a very quick question about how to utilise Zend_Db_Table with user specific
I have some very specific questions about writing operating systems that I was hoping

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.