MCPcopy Create free account
hub / github.com/bytedance/bolt / runStringViewCreate

Function runStringViewCreate

bolt/type/tests/StringViewBenchmark.cpp:38–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36namespace {
37
38void runStringViewCreate(uint32_t iterations, uint32_t len) {
39 folly::BenchmarkSuspender suspender;
40
41 const std::string chars =
42 "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
43 if (len > chars.size()) {
44 len = chars.size();
45 }
46 size_t sum = 0;
47 suspender.dismiss();
48
49 for (auto i = 0; i < iterations; i++) {
50 StringView str(chars.data() + i % (chars.size() - len), len);
51 sum += str.data()[0];
52 }
53
54 folly::doNotOptimizeAway(sum);
55}
56
57constexpr auto INLINE_SIZE = StringView::kInlineSize;
58constexpr auto NON_INLINE_SIZE = StringView::kInlineSize + 10;

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected