MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / RandomText

Function RandomText

extern/re2/re2/testing/regexp_benchmark.cc:157–174  ·  view source on GitHub ↗

Generate random text that won't contain the search string, to test worst-case search behavior.

Source from the content-addressed store, hash-verified

155// Generate random text that won't contain the search string,
156// to test worst-case search behavior.
157std::string RandomText(int64_t nbytes) {
158 static const std::string* const text = []() {
159 std::string* text = new std::string;
160 srand(1);
161 text->resize(16<<20);
162 for (int64_t i = 0; i < 16<<20; i++) {
163 // Generate a one-byte rune that isn't a control character (e.g. '\n').
164 // Clipping to 0x20 introduces some bias, but we don't need uniformity.
165 int byte = rand() & 0x7F;
166 if (byte < 0x20)
167 byte = 0x20;
168 (*text)[i] = byte;
169 }
170 return text;
171 }();
172 CHECK_LE(nbytes, 16<<20);
173 return text->substr(0, nbytes);
174}
175
176// Makes text of size nbytes, then calls run to search
177// the text for regexp iters times.

Callers 8

SearchFunction · 0.85
SearchBigFixedFunction · 0.85
FindAndConsumeFunction · 0.85
SearchSuccessFunction · 0.85
SearchAltMatchFunction · 0.85
SearchPhoneFunction · 0.85
FullMatchPCREFunction · 0.85
FullMatchRE2Function · 0.85

Calls 2

resizeMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected