This is an archive of the discontinued LLVM Phabricator instance.

Add additional benchmark functions to libcxx/benchmarks/string.bench
ClosedPublic

Authored by mvels on Jan 7 2020, 9:18 AM.

Details

Summary

This change adds the following benchmarks:

  • StringAssignStr

Assign a const basic::string& value

  • StringAssignAsciiz

Assign a const char* asciiz value

StringAssignAsciizMix
Assign mixed long/short const char* asciiz values

  • StringResizeDefaultInit

Resize default init benchmark

Event Timeline

mvels created this revision.Jan 7 2020, 9:18 AM
Herald added a project: Restricted Project. · View Herald Transcript
EricWF added inline comments.Jan 7 2020, 9:32 AM
libcxx/benchmarks/string.bench.cpp
238

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.

mvels marked an inline comment as done.Jan 7 2020, 11:14 AM
mvels added inline comments.
libcxx/benchmarks/string.bench.cpp
238

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)

EricWF accepted this revision.Jan 7 2020, 1:23 PM

I think this is fine as is. So long as you've looked at it.

LGTM.

This revision is now accepted and ready to land.Jan 7 2020, 1:23 PM