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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:48:04+00:00 2026-05-11T06:48:04+00:00

In fact i am trying to calculate the time a function takes to complete

  • 0

In fact i am trying to calculate the time a function takes to complete in my program. So i am using the logic to get system time when i call the function and time when the function returns a value then by subtracting the values i get time it took to complete. So if anyone can tell me some better approach or just how to get system time at an instance it would be quite a help

  • 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. 2026-05-11T06:48:04+00:00Added an answer on May 11, 2026 at 6:48 am

    Your question is totally dependant on WHICH system you are using. Each system has its own functions for getting the current time. For finding out how long the system has been running, you’d want to access one of the ‘high resolution performance counters’. If you don’t use a performance counter, you are usually limited to microsecond accuracy (or worse) which is almost useless in profiling the speed of a function.

    In Windows, you can access the counter via the ‘QueryPerformanceCounter()’ function. This returns an arbitrary number that is different on each processor. To find out how many ticks in the counter == 1 second, call ‘QueryPerformanceFrequency()’.

    If you’re coding under a platform other than windows, just google performance counter and the system you are coding under, and it should tell you how you can access the counter.

    Edit (clarification)
    This is c++, just include windows.h and import the ‘Kernel32.lib’ (seems to have removed my hyperlink, check out the documentation at: http://msdn.microsoft.com/en-us/library/ms644904.aspx). For C#, you can use the ‘System.Diagnostics.PerformanceCounter’ class.

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

Sidebar

Related Questions

I'm trying to run a shell command using the backtick operators, but the fact
I'm trying to calculate the number of success cases within a recursive function in
I'm trying to submit a form using JQuery. My problem comes from the fact
I'm absolutely stunned by the fact that MS just couldn't get it right to
I want to start using Python for small projects but the fact that a
I have a small C program to calculate hashes (for hash tables). The code
I am trying to figure out a way to calculate the year of birth
What I'm trying to accomplish is basically hide the fact that the page is
My fact table looks like this yesterday a yesterday a yesterday a yesterday b
I really like the fact that Microsoft has taken a commitment to bring MVC

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.