From ed0a2eb7411da5650551088905d13ed941b21e69 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Thu, 1 Oct 2015 15:08:44 -0600 Subject: [PATCH 1/2] use size_t instead of int for the iteration count --- src/benchmark.cc | 4 ++-- test/benchmark_test.cc | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/benchmark.cc b/src/benchmark.cc index c9e5888..d15ecfb 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -596,7 +596,7 @@ namespace { // Execute one thread of benchmark b for the specified number of iterations. // Adds the stats collected for the thread into *total. void RunInThread(const benchmark::internal::Benchmark::Instance* b, - int iters, int thread_id, + size_t iters, int thread_id, ThreadStats* total) EXCLUDES(GetBenchmarkLock()) { State st(iters, b->has_arg1, b->arg1, b->has_arg2, b->arg2, thread_id); b->benchmark->Run(st); @@ -613,7 +613,7 @@ void RunInThread(const benchmark::internal::Benchmark::Instance* b, void RunBenchmark(const benchmark::internal::Benchmark::Instance& b, BenchmarkReporter* br) EXCLUDES(GetBenchmarkLock()) { - int iters = 1; + size_t iters = 1; std::vector reports; diff --git a/test/benchmark_test.cc b/test/benchmark_test.cc index a23f82f..4c90398 100644 --- a/test/benchmark_test.cc +++ b/test/benchmark_test.cc @@ -101,8 +101,7 @@ static void BM_Sequential(benchmark::State& state) { for (int i = state.range_x(); --i; ) c.push_back(v); } - const int64_t items_processed = - static_cast(state.iterations()) * state.range_x(); + const size_t items_processed = state.iterations() * state.range_x(); state.SetItemsProcessed(items_processed); state.SetBytesProcessed(items_processed * sizeof(v)); } From 3dd14f07241ab52484dd14fb8427042c07c6cccc Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Thu, 1 Oct 2015 18:46:39 -0600 Subject: [PATCH 2/2] Make the type of kMaxIterations consistent with the type of the iteration count --- src/benchmark.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/benchmark.cc b/src/benchmark.cc index d15ecfb..f7b0c28 100644 --- a/src/benchmark.cc +++ b/src/benchmark.cc @@ -101,7 +101,7 @@ bool IsZero(double n) { // For non-dense Range, intermediate values are powers of kRangeMultiplier. static const int kRangeMultiplier = 8; -static const int kMaxIterations = 1000000000; +static const size_t kMaxIterations = 1000000000; bool running_benchmark = false;