diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:48 +0300 |
commit | 9abfb1a53b7f7b791444d1378e645d8fad9b06ed (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/testing/benchmark/bench.h | |
parent | 8cbc307de0221f84c80c42dcbe07d40727537e2c (diff) | |
download | ydb-9abfb1a53b7f7b791444d1378e645d8fad9b06ed.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/testing/benchmark/bench.h')
-rw-r--r-- | library/cpp/testing/benchmark/bench.h | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/library/cpp/testing/benchmark/bench.h b/library/cpp/testing/benchmark/bench.h index 5773fc1534..21551ad0dd 100644 --- a/library/cpp/testing/benchmark/bench.h +++ b/library/cpp/testing/benchmark/bench.h @@ -26,62 +26,62 @@ namespace NBench { /** * Functions that states "I can read and write everywhere in memory". - * - * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call, - * and force memory reads after it's call. - */ - void Clobber(); - + * + * Use it to prevent optimizer from reordering or discarding memory writes prior to it's call, + * and force memory reads after it's call. + */ + void Clobber(); + /** * Forces whatever `p` points to be in memory and not in register. - * - * @param Pointer to data. - */ - template <typename T> - void Escape(T* p); - -#if defined(__GNUC__) - Y_FORCE_INLINE void Clobber() { + * + * @param Pointer to data. + */ + template <typename T> + void Escape(T* p); + +#if defined(__GNUC__) + Y_FORCE_INLINE void Clobber() { asm volatile("" : : : "memory"); - } + } #elif defined(_MSC_VER) Y_FORCE_INLINE void Clobber() { _ReadWriteBarrier(); } -#else - Y_FORCE_INLINE void Clobber() { - } -#endif - -#if defined(__GNUC__) - template <typename T> - Y_FORCE_INLINE void Escape(T* p) { +#else + Y_FORCE_INLINE void Clobber() { + } +#endif + +#if defined(__GNUC__) + template <typename T> + Y_FORCE_INLINE void Escape(T* p) { asm volatile("" : : "g"(p) : "memory"); - } -#else - template <typename T> - Y_FORCE_INLINE void Escape(T*) { - } -#endif - + } +#else + template <typename T> + Y_FORCE_INLINE void Escape(T*) { + } +#endif + /** * Use this function to prevent unused variables elimination. * * @param Unused variable (e.g. return value of benchmarked function). */ - template <typename T> + template <typename T> Y_FORCE_INLINE void DoNotOptimize(T&& datum) { ::DoNotOptimizeAway(std::forward<T>(datum)); } - - int Main(int argc, char** argv); + + int Main(int argc, char** argv); } #define Y_CPU_BENCHMARK(name, cnt) \ |