Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/console_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ void ConsoleReporter::PrintRunData(const Run& result) {

for (auto& c : result.counters) {
const std::size_t cNameLen =
std::max(std::string::size_type(10), c.first.length());
std::max(static_cast<std::size_t>(10), c.first.length());
std::string s;
const char* unit = "";
if (result.run_type == Run::RT_Aggregate &&
Expand Down
8 changes: 7 additions & 1 deletion src/json_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ std::string FormatKV(std::string const& key, int64_t value) {
return ss.str();
}

std::string FormatKV(std::string const& key, int value) {
std::stringstream ss;
ss << '"' << StrEscape(key) << "\": " << value;
return ss.str();
}

std::string FormatKV(std::string const& key, double value) {
std::stringstream ss;
ss << '"' << StrEscape(key) << "\": ";
Expand Down Expand Up @@ -183,7 +189,7 @@ bool JSONReporter::ReportContext(const Context& context) {
out << ",\n";

// NOTE: our json schema is not strictly tied to the library version!
out << indent << FormatKV("json_schema_version", int64_t(1));
out << indent << FormatKV("json_schema_version", 1);

std::map<std::string, std::string>* global_context =
internal::GetGlobalContext();
Expand Down
2 changes: 1 addition & 1 deletion src/statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ std::vector<BenchmarkReporter::Run> ComputeStats(
}

const double iteration_rescale_factor =
double(reports.size()) / double(run_iterations);
static_cast<double>(reports.size()) / static_cast<double>(run_iterations);

for (const auto& Stat : *reports[0].statistics) {
// Get the data from the accumulator to BenchmarkReporter::Run's.
Expand Down
3 changes: 2 additions & 1 deletion test/basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

void BM_empty(benchmark::State& state) {
for (auto _ : state) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/diagnostics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void BM_diagnostic_test(benchmark::State& state) {
}

for (auto _ : state) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}

Expand All @@ -71,7 +72,8 @@ void BM_diagnostic_test_keep_running(benchmark::State& state) {
}

while (state.KeepRunning()) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}

Expand Down
3 changes: 2 additions & 1 deletion test/link_main_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

void BM_empty(benchmark::State& state) {
for (auto _ : state) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/memory_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class TestMemoryManager : public benchmark::MemoryManager {

void BM_empty(benchmark::State& state) {
for (auto _ : state) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/output_test_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ std::string GetFileReporterOutput(int argc, char* argv[]) {
tmp += tmp_file_name;
new_argv.emplace_back(const_cast<char*>(tmp.c_str()));

argc = int(new_argv.size());
argc = static_cast<int>(new_argv.size());

benchmark::Initialize(&argc, new_argv.data());
benchmark::RunSpecifiedBenchmarks();
Expand Down
3 changes: 2 additions & 1 deletion test/perf_counters_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ BM_DECLARE_string(benchmark_perf_counters);

static void BM_Simple(benchmark::State& state) {
for (auto _ : state) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
}
Expand Down
9 changes: 6 additions & 3 deletions test/reporter_output_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ ADD_CASES(TC_CSVOut, {{"^\"BM_basic\",%csv_report$"}});
void BM_bytes_per_second(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
state.SetBytesProcessed(1);
Expand Down Expand Up @@ -128,7 +129,8 @@ ADD_CASES(TC_CSVOut, {{"^\"BM_bytes_per_second\",%csv_bytes_report$"}});
void BM_items_per_second(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
state.SetItemsProcessed(1);
Expand Down Expand Up @@ -409,7 +411,8 @@ ADD_CASES(TC_ConsoleOut, {{"^BM_BigArgs/1073741824 %console_report$"},
void BM_Complexity_O1(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
state.SetComplexityN(state.range(0));
Expand Down
3 changes: 2 additions & 1 deletion test/skip_with_error_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ ADD_CASES("BM_error_during_running_ranged_for",

void BM_error_after_running(benchmark::State& state) {
for (auto _ : state) {
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
if (state.thread_index() <= (state.threads() / 2)) {
Expand Down
6 changes: 4 additions & 2 deletions test/user_counters_tabular_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ ADD_CASES(TC_CSVOut, {{"%csv_header,"
void BM_Counters_Tabular(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down Expand Up @@ -375,7 +376,8 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_Tabular/repeats:2/threads:2$",
void BM_CounterRates_Tabular(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down
21 changes: 14 additions & 7 deletions test/user_counters_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ int num_calls1 = 0;
void BM_Counters_WithBytesAndItemsPSec(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
state.counters["foo"] = 1;
Expand Down Expand Up @@ -119,7 +120,8 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_WithBytesAndItemsPSec",
void BM_Counters_Rate(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down Expand Up @@ -163,7 +165,8 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_Rate", &CheckRate);
void BM_Invert(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down Expand Up @@ -204,7 +207,8 @@ CHECK_BENCHMARK_RESULTS("BM_Invert", &CheckInvert);
void BM_Counters_InvertedRate(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down Expand Up @@ -333,7 +337,8 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_AvgThreads/threads:%int",
void BM_Counters_AvgThreadsRate(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down Expand Up @@ -421,7 +426,8 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_IterationInvariant",
void BM_Counters_kIsIterationInvariantRate(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down Expand Up @@ -513,7 +519,8 @@ CHECK_BENCHMARK_RESULTS("BM_Counters_AvgIterations", &CheckAvgIterations);
void BM_Counters_kAvgIterationsRate(benchmark::State& state) {
for (auto _ : state) {
// This test requires a non-zero CPU time to avoid divide-by-zero
auto iterations = double(state.iterations()) * double(state.iterations());
auto iterations = static_cast<double>(state.iterations()) *
static_cast<double>(state.iterations());
benchmark::DoNotOptimize(iterations);
}
namespace bm = benchmark;
Expand Down