-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ydb_sdk_add_library(benchmark-clobber INTERFACE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <util/system/compiler.h> | ||
|
||
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. | ||
*/ | ||
Y_FORCE_INLINE void Clobber() { | ||
#if defined(__GNUC__) | ||
asm volatile("" | ||
: | ||
: | ||
: "memory"); | ||
#elif defined(_MSC_VER) | ||
_ReadWriteBarrier(); | ||
#else | ||
// Otherwise, do nothing | ||
#endif | ||
} | ||
|
||
} // namespace NBench |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters