Thread: Timing in Windows

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    1

    Timing in Windows

    I have written C++ programs in DOS that use delay to provide millisecond timing accuracy with good results. I am now trying to write for the Windows environment, and I have been unable to find anything that will permit me to time events in the millisecond range. I understand that there are problems with accurate timing in the Windows multi-tasking environment, but I have used software that achieves accurate timing. How is it done? Borland C++Builder help and a variety of books appear to be silent on the issue.

    Thank you,
    Milton Steinberg
    Marymount College, Tarrytown NY

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    GetSystemTime() for example, will work at millisecond accuracy.

    >>> are problems with accurate timing in the Windows multi-tasking environment,

    That is not a Windows specific problem, consider, a task issues a "get time" request, (any OS), which succeeds, but then gets swapped out for another task, it then gets swapped back and the last value retrieved, which is now wrong, is returned to the application.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  3. #3
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    QueryPerformanceFrequency and QueryPerformanceCounter
    are suppose to be precise.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Hmm, the C clock() function should still work for you - no?
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Anyone using Windows 7?
    By Sharke in forum General Discussions
    Replies: 60
    Last Post: 07-12-2009, 08:05 AM
  2. Just starting Windows Programming, School me!
    By Shamino in forum Windows Programming
    Replies: 17
    Last Post: 02-22-2008, 08:14 AM
  3. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  4. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  5. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM