Path: csiph.com!news.mixmin.net!aioe.org!bgz26edc6z/2oKgnjK31sA.user.46.165.242.75.POSTED!not-for-mail From: Opus Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: what is the best way to get microseconds of time on Windows in C or C++ ? Date: Sun, 6 Nov 2022 20:53:50 +0100 Organization: Aioe.org NNTP Server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gioia.aioe.org; logging-data="13344"; posting-host="bgz26edc6z/2oKgnjK31sA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org"; User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Content-Language: fr X-Notice: Filtered by postfilter v. 0.9.2 Xref: csiph.com comp.lang.c:168143 comp.lang.c++:87269 Le 04/11/2022 à 06:06, Lynn McGuire a écrit : > I forgot to add I would prefer a portable way if possible.  I suspect > that is not possible though below the second resolution. You're asking specifically on Windows, and then you now want a portable solution. There isn't. But you could write your own compatibility layer, calling either Windows API functions or POSIX functions. This isn't rocket science. I've done that long ago and keep reusing it. There may of course be many third-party code/libraries doing just that if you don't want to do it yourself. IME, using performance counters on Windows is the only sure way of getting proper resolution. Any third-party code will use them in one way or another. Why not do that yourself, it'll be only a few lines of code to write a compatibility layer.