Discussion Overview
The discussion revolves around accurately measuring time intervals in milliseconds or less using the `clock_t` structure in C programming. Participants explore various methods and libraries available across different operating systems, including Windows and Linux, and consider the limitations of timing accuracy in different environments.
Discussion Character
- Technical explanation
- Debate/contested
- Exploratory
Main Points Raised
- One participant notes that the output from their timing code is no lower than 0.05 seconds and seeks advice on achieving millisecond accuracy.
- Another participant suggests that the `clock_t` structure may have limitations, possibly due to the resolution of the system's timer.
- A participant mentions that Windows has a default timer resolution of around 10ms, while Linux can use `rtc.h` for higher precision.
- One user inquires about using `clock_t` to measure the time taken for a loop and dividing it by the number of iterations to estimate time per iteration, questioning its accuracy.
- Another participant argues that this method may not yield accurate results due to the layers of the operating system that can affect timing.
- Discussion includes the suggestion to access hardware clocks directly for more precise timing, with references to external resources for Windows timing APIs.
- One participant questions the feasibility of running the program in DOS mode for better accuracy and asks about using Windows APIs with TurboC.
- Several participants provide links to documentation and tutorials for using Windows APIs to access system time, while also expressing concerns about the accuracy of these methods below 0.1 seconds.
- There is mention of routines that provide access to hardware time events, with a suggestion that they could be adapted for use in various C compilers.
Areas of Agreement / Disagreement
Participants express differing views on the accuracy of various timing methods, with no consensus on the best approach. Some advocate for using hardware clocks for precision, while others suggest using system APIs, acknowledging limitations in accuracy.
Contextual Notes
Limitations include the dependency on operating system behavior, potential inaccuracies due to multitasking environments, and the resolution of the timers used in different systems. The discussion does not resolve these issues.