Fix build errors.

PiperOrigin-RevId: 278310119
This commit is contained in:
Victor Costan 2019-11-03 23:22:24 -08:00 committed by Victor Costan
parent eb2eb73e6b
commit c9212708b2
3 changed files with 16 additions and 14 deletions

View File

@ -67,7 +67,7 @@ std::string ReadTestDataFile(const std::string& base) {
return ReadTestDataFile(base, 0);
}
std::string StringPrintf(const char* format, ...) {
std::string StrFormat(const char* format, ...) {
char buf[4096];
va_list ap;
va_start(ap, format);
@ -217,7 +217,7 @@ void Benchmark::Run() {
benchmark_runs[run].cpu_time_us = benchmark_cpu_time_us;
}
std::string heading = StringPrintf("%s/%d", name_.c_str(), test_case_num);
std::string heading = StrFormat("%s/%d", name_.c_str(), test_case_num);
std::string human_readable_speed;
std::nth_element(benchmark_runs,
@ -232,15 +232,16 @@ void Benchmark::Run() {
int64 bytes_per_second =
benchmark_bytes_processed * 1000000 / cpu_time_us;
if (bytes_per_second < 1024) {
human_readable_speed = StringPrintf("%dB/s", bytes_per_second);
human_readable_speed =
StrFormat("%dB/s", static_cast<int>(bytes_per_second));
} else if (bytes_per_second < 1024 * 1024) {
human_readable_speed = StringPrintf(
human_readable_speed = StrFormat(
"%.1fkB/s", bytes_per_second / 1024.0f);
} else if (bytes_per_second < 1024 * 1024 * 1024) {
human_readable_speed = StringPrintf(
human_readable_speed = StrFormat(
"%.1fMB/s", bytes_per_second / (1024.0f * 1024.0f));
} else {
human_readable_speed = StringPrintf(
human_readable_speed = StrFormat(
"%.1fGB/s", bytes_per_second / (1024.0f * 1024.0f * 1024.0f));
}
}

View File

@ -187,7 +187,7 @@ std::string ReadTestDataFile(const std::string& base);
// A sprintf() variant that returns a std::string.
// Not safe for general use due to truncation issues.
std::string StringPrintf(const char* format, ...);
std::string StrFormat(const char* format, ...);
// A wall-time clock. This stub is not super-accurate, nor resistant to the
// system time changing.

View File

@ -346,7 +346,7 @@ static void Measure(const char* data,
float uncomp_rate = (length / utime[med]) * repeats / 1048576.0;
std::string x = names[comp];
x += ":";
std::string urate = (uncomp_rate >= 0) ? absl::StrFormat("%.1f", uncomp_rate)
std::string urate = (uncomp_rate >= 0) ? StrFormat("%.1f", uncomp_rate)
: std::string("?");
printf("%-7s [b %dM] bytes %6d -> %6d %4.1f%% "
"comp %5.1f MB/s uncomp %5s MB/s\n",
@ -582,7 +582,7 @@ TEST(CorruptedTest, VerifyCorrupted) {
// try reading stuff in from a bad file.
for (int i = 1; i <= 3; ++i) {
std::string data =
ReadTestDataFile(absl::StrFormat("baddata%d.snappy", i).c_str(), 0);
ReadTestDataFile(StrFormat("baddata%d.snappy", i).c_str(), 0);
std::string uncmp;
// check that we don't return a crazy length
size_t ulen;
@ -1401,10 +1401,11 @@ static void BM_ZFlat(int iters, int arg) {
StopBenchmarkTiming();
const double compression_ratio =
static_cast<double>(zsize) / std::max<size_t>(1, contents.size());
SetBenchmarkLabel(absl::StrFormat("%s (%.2f %%)", files[arg].label,
SetBenchmarkLabel(StrFormat("%s (%.2f %%)", files[arg].label,
100.0 * compression_ratio));
VLOG(0) << StringPrintf("compression for %s: %zd -> %zd bytes",
files[arg].label, contents.size(), zsize);
VLOG(0) << StrFormat("compression for %s: %zd -> %zd bytes",
files[arg].label, static_cast<int>(contents.size()),
static_cast<int>(zsize));
delete[] dst;
}
BENCHMARK(BM_ZFlat)->DenseRange(0, ARRAYSIZE(files) - 1);
@ -1440,7 +1441,7 @@ static void BM_ZFlatAll(int iters, int arg) {
for (int i = 0; i < num_files; ++i) {
delete[] dst[i];
}
SetBenchmarkLabel(absl::StrFormat("%d files", num_files));
SetBenchmarkLabel(StrFormat("%d files", num_files));
}
BENCHMARK(BM_ZFlatAll)->DenseRange(0, 0);