// Add the global baseline
BENCHMARK(globalBenchmarkBaseline) {
+#ifdef _MSC_VER
+ _ReadWriteBarrier();
+#else
asm volatile("");
+#endif
}
void detail::addBenchmarkImpl(const char* file, const char* name,
// the clock resolution is worse than that, it will be larger. In
// essence we're aiming at making the quantization noise 0.01%.
static const auto minNanoseconds =
- max(FLAGS_bm_min_usec * 1000UL,
+ max<uint64_t>(FLAGS_bm_min_usec * 1000UL,
min<uint64_t>(resolutionInNs * 100000, 1000000000ULL));
// We do measurements in several epochs and take the minimum, to
* good job at eliminating unused variables, and this function fools
* it into thinking var is in fact needed.
*/
+#ifdef _MSC_VER
+
+#pragma optimize("", off)
+
+template <class T>
+void doNotOptimizeAway(T&& datum) {
+ datum = datum;
+}
+
+#pragma optimize("", on)
+
+#else
template <class T>
void doNotOptimizeAway(T&& datum) {
asm volatile("" : "+r" (datum));
}
+#endif
} // namespace folly
* FB_ONE_OR_NONE(hello) expands to nothing. This macro is used to
* insert or eliminate text based on the presence of another argument.
*/
+#ifdef _MSC_VER
+
+#define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N
+#define VA_NARGS(...) VA_NARGS_IMPL(X,##__VA_ARGS__, 4, 3, 2, 1, 0)
+#define VARARG_IMPL2(base, count, ...) base##count(__VA_ARGS__)
+#define VARARG_IMPL(base, count, ...) VARARG_IMPL2(base, count, __VA_ARGS__)
+#define VARARG(base, ...) VARARG_IMPL(base, VA_NARGS(__VA_ARGS__), __VA_ARGS__)
+
+#define FB_ONE_OR_NONE0() /* */
+#define FB_ONE_OR_NONE1(x) /* */
+#define FB_ONE_OR_NONE2(x, y) x
+#define FB_ONE_OR_NONE3(x, y, z) x
+#define FB_ONE_OR_NONE(...) VARARG(FB_ONE_OR_NONE, __VA_ARGS__)
+
+#else
#define FB_ONE_OR_NONE(a, ...) FB_THIRD(a, ## __VA_ARGS__, a)
#define FB_THIRD(a, b, ...) __VA_ARGS__
+#endif
/**
* Helper macro that extracts the first argument out of a list of any