Can I get the time "Duration" in "nsecs" acurracy?
rempas
rempas at tutanota.com
Sat Jul 10 06:28:43 UTC 2021
On Friday, 9 July 2021 at 21:04:42 UTC, Ali Çehreli wrote:
> On 7/9/21 1:54 PM, Paul Backus wrote:
>> [...]
>
> Yes but the resolution seems not to be better than 100 nsecs. A
> quick research reveals a better resolution is not possible with
> common hardware on at least Linux.
>
> The following program always prints multiples of 100 on my Mint
> OS:
>
> import std.stdio;
> import core.thread;
> import std.datetime.stopwatch;
>
> void main() {
> auto sw = StopWatch();
> sw.start();
>
> foreach (_; 0..10) {
> Thread.sleep(0.nsecs);
> writefln("%,s", sw.peek.total!"nsecs");
> }
> }
>
> Ali
So it's an OS thing? C++ with "std::chrono" can show me less than
1 hnsec (100 nanoseconds) accuracy.
More information about the Digitalmars-d-learn
mailing list