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
24 changes: 13 additions & 11 deletions include/benchmark/benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,10 +505,10 @@ class State {
//
// REQUIRES: a benchmark has exited its benchmarking loop.
BENCHMARK_ALWAYS_INLINE
void SetBytesProcessed(size_t bytes) { bytes_processed_ = bytes; }
void SetBytesProcessed(int64_t bytes) { bytes_processed_ = bytes; }

BENCHMARK_ALWAYS_INLINE
size_t bytes_processed() const { return bytes_processed_; }
int64_t bytes_processed() const { return bytes_processed_; }

// If this routine is called with complexity_n > 0 and complexity report is
// requested for the
Expand All @@ -528,10 +528,10 @@ class State {
//
// REQUIRES: a benchmark has exited its benchmarking loop.
BENCHMARK_ALWAYS_INLINE
void SetItemsProcessed(size_t items) { items_processed_ = items; }
void SetItemsProcessed(int64_t items) { items_processed_ = items; }

BENCHMARK_ALWAYS_INLINE
size_t items_processed() const { return items_processed_; }
int64_t items_processed() const { return items_processed_; }

// If this routine is called, the specified label is printed at the
// end of the benchmark report line for the currently executing
Expand Down Expand Up @@ -565,17 +565,19 @@ class State {
int range_y() const { return range(1); }

BENCHMARK_ALWAYS_INLINE
size_t iterations() const { return (max_iterations - total_iterations_) + 1; }
int64_t iterations() const {
return static_cast<int64_t>(max_iterations - total_iterations_) + 1;
}

private:
bool started_;
bool finished_;
size_t total_iterations_;
int32_t total_iterations_;

std::vector<int> range_;

size_t bytes_processed_;
size_t items_processed_;
int64_t bytes_processed_;
int64_t items_processed_;

int complexity_n_;

Expand All @@ -588,10 +590,10 @@ class State {
const int thread_index;
// Number of threads concurrently executing the benchmark.
const int threads;
const size_t max_iterations;
const int32_t max_iterations;

// TODO(EricWF) make me private
State(size_t max_iters, const std::vector<int>& ranges, int thread_i,
State(int32_t max_iters, const std::vector<int>& ranges, int thread_i,
int n_threads, internal::ThreadTimer* timer,
internal::ThreadManager* manager);

Expand Down Expand Up @@ -638,7 +640,7 @@ struct State::StateIterator {
}

private:
size_t cached_;
int32_t cached_;
State* const parent_;
};

Expand Down
14 changes: 7 additions & 7 deletions src/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ DEFINE_int32(v, 0, "The level of verbose logging to output");
namespace benchmark {

namespace {
static const size_t kMaxIterations = 1000000000;
static const int32_t kMaxIterations = 1000000000;
} // end namespace

namespace internal {
Expand Down Expand Up @@ -140,8 +140,8 @@ class ThreadManager {
double real_time_used = 0;
double cpu_time_used = 0;
double manual_time_used = 0;
int64_t bytes_processed = 0;
int64_t items_processed = 0;
uint64_t bytes_processed = 0;
uint64_t items_processed = 0;
int complexity_n = 0;
std::string report_label_;
std::string error_message_;
Expand Down Expand Up @@ -219,7 +219,7 @@ namespace {

BenchmarkReporter::Run CreateRunReport(
const benchmark::internal::Benchmark::Instance& b,
const internal::ThreadManager::Result& results, size_t iters,
const internal::ThreadManager::Result& results, int32_t iters,
double seconds) {
// Create report about this benchmark run.
BenchmarkReporter::Run report;
Expand Down Expand Up @@ -263,7 +263,7 @@ BenchmarkReporter::Run CreateRunReport(
// 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,
size_t iters, int thread_id,
int32_t iters, int thread_id,
internal::ThreadManager* manager) {
internal::ThreadTimer timer;
State st(iters, b->arg, thread_id, b->threads, &timer, manager);
Expand All @@ -290,7 +290,7 @@ std::vector<BenchmarkReporter::Run> RunBenchmark(
std::vector<BenchmarkReporter::Run> reports; // return value

const bool has_explicit_iteration_count = b.iterations != 0;
size_t iters = has_explicit_iteration_count ? b.iterations : 1;
int32_t iters = has_explicit_iteration_count ? b.iterations : 1;
std::unique_ptr<internal::ThreadManager> manager;
std::vector<std::thread> pool(b.threads - 1);
const int repeats =
Expand Down Expand Up @@ -394,7 +394,7 @@ std::vector<BenchmarkReporter::Run> RunBenchmark(
} // namespace
} // namespace internal

State::State(size_t max_iters, const std::vector<int>& ranges, int thread_i,
State::State(int32_t max_iters, const std::vector<int>& ranges, int thread_i,
int n_threads, internal::ThreadTimer* timer,
internal::ThreadManager* manager)
: started_(false),
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct Benchmark::Instance {
bool last_benchmark_instance;
int repetitions;
double min_time;
size_t iterations;
int32_t iterations;
int threads; // Number of concurrent threads to us
};

Expand Down
4 changes: 2 additions & 2 deletions test/basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ BENCHMARK(BM_empty_stop_start)->ThreadPerCpu();


void BM_KeepRunning(benchmark::State& state) {
size_t iter_count = 0;
int32_t iter_count = 0;
while (state.KeepRunning()) {
++iter_count;
}
Expand All @@ -107,7 +107,7 @@ void BM_KeepRunning(benchmark::State& state) {
BENCHMARK(BM_KeepRunning);

void BM_RangedFor(benchmark::State& state) {
size_t iter_count = 0;
int32_t iter_count = 0;
for (auto _ : state) {
++iter_count;
}
Expand Down