This is an archive of the discontinued LLVM Phabricator instance.

Add benchmarks for string assign methods
ClosedPublic

Authored by mvels on Sep 17 2019, 9:29 AM.

Details

Summary

string.assign() heavily contributes to application's CPU usage.

This change adds benchmarks for the assign(const basic_string&) and assign(const char*) methods to be used to benchmark current usage and potential optimizations.

Event Timeline

mvels created this revision.Sep 17 2019, 9:29 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2019, 9:29 AM
EricWF accepted this revision.Sep 24 2019, 10:10 AM

LGTM.

libcxx/benchmarks/string.bench.cpp
267

Escape this memory with DoNotOptimize before entering the loop.

289

constexpr Opaque O{};?

This revision is now accepted and ready to land.Sep 24 2019, 10:10 AM
mvels updated this revision to Diff 221565.Sep 24 2019, 11:07 AM
mvels marked an inline comment as done.

Resolved comments

mvels marked an inline comment as done.Sep 24 2019, 11:08 AM
mvels added inline comments.
libcxx/benchmarks/string.bench.cpp
267

This is done already per batch right after the batch is cleared, unless I miss something?

mvels marked an inline comment as done.Sep 25 2019, 7:05 AM
mvels updated this revision to Diff 222619.Oct 1 2019, 7:54 AM
  • Optimize operator=(const basic_string&) for tail call.
mvels updated this revision to Diff 222621.Oct 1 2019, 7:59 AM