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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:43:08+00:00 2026-05-26T09:43:08+00:00

I am new to C++ , I have a program in C++ written for

  • 0

I am new to C++ , I have a program in C++ written for Linux. I’m trying to convert it to Windows. The code I have is:

struct Timer 
{  
    struct tms t[2];
    void STARTTIME (void)
    {
        times(t);
    }

    void  STOPTIME(void)
    {
       times(t+1);
    }

    double USERTIME(void)
    {
        return ((double)((t+1)->tms_utime - t->tms_utime))/((double)sysconf(_SC_CLK_TCK));
    }
};

For tms_utime I find term QueryPerformanceCounter in Visual C++, but I cannot apply this.
For sysconf(_SC_CLK_TCK) I use CLOCKS_PER_SEC but I do not know how correct this is? What is the equivalent code for Windows?

  • 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-26T09:43:08+00:00Added an answer on May 26, 2026 at 9:43 am

    Here is a drop-in replacement that returns the user time, rather than the elapsed time:

    #include <windows.h>
    
    struct Timer 
    {  
        ULONGLONG t[2];
    
        void STARTTIME (void)
        {
            t[0] = getCurrentUserTime();
        }
    
        void  STOPTIME(void)
        {
            t[1] = getCurrentUserTime();
        }
    
        double USERTIME(void)
        {
            return (t[1] - t[0]) / 1e7; 
        }
    
    private:
        // Return current user time in units of 100ns.
        // See http://msdn.microsoft.com/en-us/library/ms683223
        // for documentation on GetProcessTimes()
        ULONGLONG getCurrentUserTime()
        {
            FILETIME ct, et, kt, ut;
            GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut);
            ULARGE_INTEGER t;
            t.HighPart = ut.dwHighDateTime;
            t.LowPart = ut.dwLowDateTime;
            return t.QuadPart;
        }
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: class Program { static void Main(string[] args) { new
I am trying to port a Linux program written in C to Windows. In
I am very new to JAVA. I have written simple program (in Linux -VIM
I have some code that effectively does this : File file = new File(C:\\Program
I have the following code in my program: Thread getUsersist, getChatUsers; getUsersList = new
I am new to Qt . I have written a program to read and
i'm trying to debug a program, that i don't have the source code for:
I have written down a program in c and I am trying to create
I have a program written in Delphi-7 which opens a new Word document which
We have a windows program written in vbasic(i think) and we are re-writing the

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.