26 "01234567890123456789",
27 "012345\x1B[0;35m67890123456789",
28 "abcd\x1b[1;31mefg\x1b[0mhlkmnopqrstuvwxyz",
32 std::vector<int> times;
34 int64_t kMaxTimeMillis = 5 * 1000;
37 const int kRuns = 100;
38 for (
int j = 0; j < kRuns; ++j) {
40 if (start >= base_time + kMaxTimeMillis)
43 const int kNumRepetitions = 2000;
44 for (
int count = kNumRepetitions; count > 0; --count) {
46 size_t input_len = ::strlen(input);
47 for (
size_t max_width = input_len; max_width > 0; --max_width) {
48 std::string str(input, input_len);
55 times.push_back(delta);
61 for (
size_t i = 0; i < times.size(); ++i) {
65 else if (times[i] > max)
69 printf(
"min %dms max %dms avg %.1fms\n", min, max, total / times.size());
void ElideMiddleInPlace(std::string &str, size_t max_width)
Elide the given string str with '...' in the middle if the length exceeds max_width.
static const char * kTestInputs[]
int64_t GetTimeMillis()
Get the current time as relative to some epoch.
signed long long int64_t
A 64-bit integer type.