[PATCH] D40162: [XRay][test-suite] Update XRay microbenchmarks to use ranged for loops

Eizan Miyamoto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 16 17:52:58 PST 2017


eizan created this revision.

This is slightly more efficient and is now supported by benchmark 1.3.0


https://reviews.llvm.org/D40162

Files:
  MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc
  MicroBenchmarks/XRay/ReturnReference/retref-bench.cc


Index: MicroBenchmarks/XRay/ReturnReference/retref-bench.cc
===================================================================
--- MicroBenchmarks/XRay/ReturnReference/retref-bench.cc
+++ MicroBenchmarks/XRay/ReturnReference/retref-bench.cc
@@ -25,7 +25,7 @@
 
 [[clang::xray_never_instrument]] static void BM_ReturnNeverInstrumented(
     benchmark::State& state) {
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     benchmark::DoNotOptimize(neverInstrumented());
   }
 }
@@ -41,7 +41,7 @@
 [[clang::xray_never_instrument]] static void BM_ReturnInstrumentedUnPatched(
     benchmark::State& state) {
   __xray_unpatch();
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     int x;
     benchmark::DoNotOptimize(x = alwaysInstrumented());
     benchmark::ClobberMemory();
@@ -55,7 +55,7 @@
     benchmark::State& state) {
   __xray_patch();
   __xray_unpatch();
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     int x;
     benchmark::DoNotOptimize(x = alwaysInstrumented());
     benchmark::ClobberMemory();
@@ -68,7 +68,7 @@
 [[clang::xray_never_instrument]] static void BM_ReturnInstrumentedPatched(
     benchmark::State& state) {
   __xray_patch();
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     int x;
     benchmark::DoNotOptimize(alwaysInstrumented());
     benchmark::ClobberMemory();
@@ -79,7 +79,7 @@
 
 [[clang::xray_never_instrument]] static void BM_RDTSCP_Cost(
     benchmark::State& state) {
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     unsigned cpu;
     unsigned tsc;
     benchmark::DoNotOptimize(tsc = __rdtscp(&cpu));
@@ -104,7 +104,7 @@
   __xray_set_handler(benchmark_handler);
   __xray_patch();
   benchmark::ClobberMemory();
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     int x;
     benchmark::DoNotOptimize(x = alwaysInstrumented());
     benchmark::ClobberMemory();
Index: MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc
===================================================================
--- MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc
+++ MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc
@@ -71,7 +71,7 @@
   if (state.thread_index == 0) {
     SetUpXRayFDRMultiThreaded(state);
   }
-  while (state.KeepRunning()) {
+  for (auto _ : state) {
     val = EmptyFunction();
     benchmark::DoNotOptimize(val);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40162.123279.patch
Type: text/x-patch
Size: 2332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171117/9952fc57/attachment.bin>


More information about the llvm-commits mailing list