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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:52:26+00:00 2026-05-30T14:52:26+00:00

Possible Duplicate: Environment.TickCount vs DateTime.Now In my application I require fast timing operations but

  • 0

Possible Duplicate:
Environment.TickCount vs DateTime.Now

In my application I require fast timing operations but accuracy is not that important. I checked the runtime speed of the three timing operations for which I am familiar with and came up with these results:

for (int i = 0; i < 1000000; i++) 
{
    // var time = (DateTime.Now - dt).TotalMilliseconds; // 1131 ms
    // var time = (Environment.TickCount - dt); // 7 ms
    // var time = stopwatch.ElapsedMilliseconds; // 131 ms
}

The times were checked using a Stopwatch. So, I want to use Environment.TickCount (I think!) but its problem is that after 24.9 days if the user is very unlucky the operation of 2,147,483,647 - -2,147,483,648 will occur and result in an overflow error and crash the program.

So, my question is two-fold. Firstly, is Environment.TickCount the best tool for the job given my specified goals, and secondly, whether anyone else has written a wrapper class for it and if so, how did you take in to account the rare overflow chance?

  • 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-05-30T14:52:28+00:00Added an answer on May 30, 2026 at 2:52 pm

    While I think it is duplicate of discussion on TickCount vs. Now…

    Is TickCount the best tool you need to decide yourself. If 100ms matters for 1 million of operations you plan to measure – probably, but I strongly doubt as precision of TickCount is 10ms your average error for that many measurements would be about 5ms*10^6.

    I think you should create wrapper class for your time measurement, but mainly not to protect from wraparound, but to allow unit testing of your code. It is not easy to mock system-wide time functions, but custom class can be setup for ease of use and testing.

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

Sidebar

Related Questions

Possible Duplicate: What's the difference between .bashrc, .bash_profile, and .environment? It seems that if
Possible Duplicate: Access shell environment variables Java I've created a stand-alone java application in
Possible Duplicate: Seemingly useless debugging environment for Android I've obviously been spoiled by Visual
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
Possible Duplicate: Exporting an Environment Variable in Ruby I need to set several environment
Possible Duplicate: What Web Application Framework for Delphi is recommended? We have a Delphi
Possible Duplicate: Getting a value from HttpServletRequest.getRemoteUser() in Tomcat without modifying application Short version:
Possible Duplicate: Calling a webservice that uses ISO-8859-1 encoding from WCF I am trying
Possible Duplicate: Eclipse Android SDK slow Content Assist performance For reasons not worth discussing
Possible Duplicate: How to read Linux environment variables in c++ How can the following

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.