in Education by
I am porting a game, that was originally written for the Win32 API, to Linux (well, porting the OS X port of the Win32 port to Linux). I have implemented QueryPerformanceCounter by giving the uSeconds since the process start up: BOOL QueryPerformanceCounter(LARGE_INTEGER* performanceCount) { gettimeofday(&currentTimeVal, NULL); performanceCount->QuadPart = (currentTimeVal.tv_sec - startTimeVal.tv_sec); performanceCount->QuadPart *= (1000 * 1000); performanceCount->QuadPart += (currentTimeVal.tv_usec - startTimeVal.tv_usec); return true; } This, coupled with QueryPerformanceFrequency() giving a constant 1000000 as the frequency, works well on my machine, giving me a 64-bit variable that contains uSeconds since the program's start-up. So is this portable? I don't want to discover it works differently if the kernel was compiled in a certain way or anything like that. I am fine with it being non-portable to something other than Linux, however. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Maybe. But you have bigger problems. gettimeofday() can result in incorrect timings if there are processes on your system that change the timer (ie, ntpd). On a "normal" linux, though, I believe the resolution of gettimeofday() is 10us. It can jump forward and backward and time, consequently, based on the processes running on your system. This effectively makes the answer to your question no. You should look into clock_gettime(CLOCK_MONOTONIC) for timing intervals. It suffers from several less issues due to things like multi-core systems and external clock settings. Also, look into the clock_getres() function.

Related questions

0 votes
    When I iterate over the values or keys are they going to correlate? Will the second key map to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I have many automated integration tests. Some of them are negative-case tests, which make sure that my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    Explain with reasons whether the following statements are true or false: A resolution can be passed even if China exercises its veto power. Please answer the above question....
asked Aug 14, 2022 in Education by JackTerrance
0 votes
    What is Coreference Resolution? (a) Anaphora Resolution (b) Given a sentence or larger chunk of text, determine which ... d) None of the mentioned Please answer the above question....
asked Oct 22, 2022 in Education by JackTerrance
0 votes
    What is Coreference Resolution? (a) Anaphora Resolution (b) Given a sentence or larger chunk of text, determine which ... d) None of the mentioned Please answer the above question....
asked Oct 2, 2022 in Education by JackTerrance
0 votes
    I have three text fields and submit button on a browser page.. Lets say A, B, C, and submit ( ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I'm having some trouble understanding the changes made to the coref resolver in the last version of the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Fill in the Blanks. (5) A. is a type of scanner that is used to capture the highest resolution from an image. Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    What are the resolution steps when Burp does not intercept HTTPS requests? A)Toinstall Burp's CA certificate ... browser configuration. Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Which Azure networking component is the core unit, from which administrators can have full control over IP address ... . Load Balancers 3. Routing Tables 4. Local Network...
asked Sep 22, 2021 in Technology by JackTerrance
0 votes
    What is Scope Resolution in Python?...
asked Dec 6, 2020 in Technology by JackTerrance
+1 vote
    Which Azure networking component is the core unit from which administrators can have full control over IP address ... , name resolution, security settings, and routing rules?...
asked Oct 20, 2020 in Technology by JackTerrance
+1 vote
    Which Azure networking component is the core unit from which administrators can have full control over IP address ... , name resolution, security settings, and routing rules?...
asked Oct 20, 2020 in Technology by JackTerrance
0 votes
    In computer security _______ means that the information in a computer system only be accessible for reading by ... . integrity B. confidentiality C. authenticity D. availability...
asked Mar 12, 2023 in Technology by JackTerrance
...