[PATCH] D64082: [MemFunctions] Add microbenchmarks for memory functions.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 2 11:28:56 PDT 2019


lebedev.ri added a comment.

In D64082#1566955 <https://reviews.llvm.org/D64082#1566955>, @spatel wrote:

> Thanks for working on this! I'm not familiar with how the benchmarking framework works, so someone else should definitely have a look.


That could be me, i suppose.
Does not look too wrong to me.

> Does the framework automatically account for and filter out noisy results? I'm guessing that tiny memcmp() will have a lot of run-to-run variation.

The `for (auto _ : state)` loop will run for up to 0.5 sec, so the results should be good;
Plus at the test-suite/lnt level the test suite can be run several times so it's possible ensure that timing changes are meaningful (T Test, e.g.)



================
Comment at: MicroBenchmarks/MemFunctions/main.cpp:34-38
+  const char* q = q_storage.data();
+
+  for (int i = 0; i < kNumElements; ++i)
+    Mod().template Change<kSize>(p + i * kSize);
+
----------------
So what about `q`? It's intentionally left all-zeros? That warrants a comment.


================
Comment at: MicroBenchmarks/MemFunctions/main.cpp:82-94
+#define MEMCMP_BENCHMARK(size) \
+  BENCHMARK_TEMPLATE(BM_MemCmp, size, EqZero, None)->Unit(benchmark::kNanosecond); \
+  BENCHMARK_TEMPLATE(BM_MemCmp, size, EqZero, First)->Unit(benchmark::kNanosecond); \
+  BENCHMARK_TEMPLATE(BM_MemCmp, size, EqZero, Mid)->Unit(benchmark::kNanosecond); \
+  BENCHMARK_TEMPLATE(BM_MemCmp, size, EqZero, Last)->Unit(benchmark::kNanosecond); \
+  BENCHMARK_TEMPLATE(BM_MemCmp, size, LessThanZero, None)->Unit(benchmark::kNanosecond); \
+  BENCHMARK_TEMPLATE(BM_MemCmp, size, LessThanZero, First)->Unit(benchmark::kNanosecond); \
----------------
I'd do one or two macro levels here


================
Comment at: MicroBenchmarks/MemFunctions/main.cpp:111-118
+int main(int argc, char *argv[]) {
+  ::benchmark::Initialize(&argc, argv);
+  if (::benchmark::ReportUnrecognizedArguments(argc, argv))
+    return 1;
+  ::benchmark::RunSpecifiedBenchmarks();
+
+  return 0;
----------------
BENCHMARK_MAIN();



Repository:
  rT test-suite

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64082/new/

https://reviews.llvm.org/D64082





More information about the llvm-commits mailing list