MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / generateRandomString

Function generateRandomString

programs/keeper-bench/Generator.cpp:31–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace
30{
31std::string generateRandomString(size_t length, pcg64 & rng)
32{
33 if (length == 0)
34 return "";
35
36 static const auto & chars = "0123456789"
37 "abcdefghijklmnopqrstuvwxyz"
38 "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
39
40 std::uniform_int_distribution<size_t> pick(0, sizeof(chars) - 2);
41
42 std::string s;
43
44 s.reserve(length);
45
46 while (length--)
47 s += chars[pick(rng)];
48
49 return s;
50}
51}
52
53NumberGetter

Callers 1

getStringMethod · 0.85

Calls 1

reserveMethod · 0.45

Tested by

no test coverage detected