- Visual C++ 2019 is having a hissy fit over these two lines of code - 3 Updates
- How long does x86 PAUSE last ? - 2 Updates
- OOD idea of C++ and class coding guide lines - 1 Update
- Is this safe? - 1 Update
Bonita Montero <Bonita.Montero@gmail.com>: Jul 21 04:51AM +0200 Am 20.07.2023 um 21:57 schrieb Chris M. Thomasson: >> For me is #define-ing NOMIMMAX before including <Windows.h> >> the smarter solution. > Don't forget WIN32_LEAN_AND_MEAN ... :^) That's 100ms difference when compiling for me (7950X). |
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Jul 20 11:20PM -0400 Alf P. Steinbach wrote: > Visual C++ and g++. > Not what you're asking but note that > * `typedef` is old C syntax, modern `using` can be more clear. Any code is written to be read by humans. Uniform hurts the readability, specific improves it. Plus, using declaration make the reader read more tokens. Upshot: use typedef where you can and using where you can't. > * `const` at namespace scope implies `static`, i.e. no need to repeat. Another change from more to less readable code. In order to know a declaration is in a namespace, one has to either keep this in mind or look up. The former is inefficient in space, the latter -- in time. Upshot: feel free to be helpful and use static. Morale: a new shiny multitool is not a universally good replacement for the old good pliers. > using ssize_t_2 = array_of_2_<ssize_t> ; > } // namespace fem > - Alf Cheers, -Pavel |
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jul 21 12:59PM -0700 On 7/20/2023 7:51 PM, Bonita Montero wrote: >> Don't forget WIN32_LEAN_AND_MEAN ... :^) > That's 100ms difference when compiling for me (7950X). :^) Still, its something that was ingrained in my brain from long ago. |
Bonita Montero <Bonita.Montero@gmail.com>: Jul 21 11:15AM +0200 Years ago I wrote a mutex that allows multiple read accesses or exclusive write access. Instead, I use limited configurable spinning. Each spinning interval has an x86 PAUSE instruction to conserve power and not suffocate other threads on the core. This got me wondering how long a PAUSE instruction takes on different x86 CPUs. That's why I wrote a small test C++20 program that you can try out. Here it is: #include <iostream> #include <chrono> #include <cstdint> #include <utility> #if defined(_MSC_VER) #include <intrin.h> #else #include <x86intrin.h>
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment