[libcxx-commits] [PATCH] D72343: Add additional benchmark functions to libcxx/benchmarks/string.bench

Martijn Vels via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 7 11:21:36 PST 2020


mvels marked an inline comment as done.
mvels added inline comments.


================
Comment at: libcxx/benchmarks/string.bench.cpp:238
+template <class Length, class Opaque>
+struct StringResizeDefaultInit {
+  static void run(benchmark::State& state) {
----------------
EricWF wrote:
> Have you looked at the dissasembly for these benchmarks? They scare me a little bit. I think the compiler may be able to optimize large chunks of them away.
I did look at the assembly, the compiler does not optimize out branches for either the opaque or transparent call paths, which makes sense as the compiler would be hard pressed to proof the constantness of the strings array.

There is basically no difference here between transparent and opaque, as there is no 'inlined' memset, memcpy, or other optimizations that would deeply separate the 2 of them other than a predicted branch which does not change much timing wise for short strings.

Given that the main purpose for this bench is more on baseline for inlined resize (always fast) and long resize (now through __grow_by),  we could make it an 'Opaque only' test as this is not something where the difference between compile time known input (length) should make much of a difference (if any)

 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72343





More information about the libcxx-commits mailing list