Skip to content

Commit

Permalink
Set(Items|Bytes)Processed now take int64_t
Browse files Browse the repository at this point in the history
  • Loading branch information
dmah42 committed Apr 3, 2018
1 parent 1fe8299 commit 250d0a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
12 changes: 6 additions & 6 deletions include/benchmark/benchmark.h
Expand Up @@ -514,10 +514,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 @@ -537,10 +537,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 @@ -600,8 +600,8 @@ class State {
private: // items we don't need on the first cache line
std::vector<int64_t> range_;

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

int64_t complexity_n_;

Expand Down
12 changes: 7 additions & 5 deletions test/BUILD
Expand Up @@ -35,7 +35,8 @@ cc_library(
],
)

[cc_test(
[
cc_test(
name = test_src[:-len(".cc")],
size = "small",
srcs = [test_src],
Expand All @@ -49,7 +50,8 @@ cc_library(
] + (
["@com_google_googletest//:gtest_main"] if (test_src[-len("gtest.cc"):] == "gtest.cc") else []
),
# FIXME: Add support for assembly tests to bazel.
# See Issue #556
# https://github.com/google/benchmark/issues/556
) for test_src in glob(["*test.cc"], exclude = ["*_assembly_test.cc"])]
# FIXME: Add support for assembly tests to bazel.
# See Issue #556
# https://github.com/google/benchmark/issues/556
) for test_src in glob(["*test.cc"], exclude = ["*_assembly_test.cc"])
]
9 changes: 5 additions & 4 deletions test/benchmark_test.cc
Expand Up @@ -105,7 +105,7 @@ static void BM_Sequential(benchmark::State& state) {
Container c;
for (int64_t i = state.range(0); --i;) c.push_back(v);
}
const size_t items_processed = state.iterations() * state.range(0);
const int64_t items_processed = state.iterations() * state.range(0);
state.SetItemsProcessed(items_processed);
state.SetBytesProcessed(items_processed * sizeof(v));
}
Expand All @@ -118,8 +118,9 @@ BENCHMARK_TEMPLATE(BM_Sequential, std::vector<int>, int)->Arg(512);
#endif

static void BM_StringCompare(benchmark::State& state) {
std::string s1(state.range(0), '-');
std::string s2(state.range(0), '-');
size_t len = static_cast<size_t>(state.range(0));
std::string s1(len, '-');
std::string s2(len, '-');
for (auto _ : state) benchmark::DoNotOptimize(s1.compare(s2));
}
BENCHMARK(BM_StringCompare)->Range(1, 1 << 20);
Expand Down Expand Up @@ -160,7 +161,7 @@ static void BM_ParallelMemset(benchmark::State& state) {
int to = from + thread_size;

if (state.thread_index == 0) {
test_vector = new std::vector<int>(size);
test_vector = new std::vector<int>(static_cast<size_t>(size));
}

for (auto _ : state) {
Expand Down

0 comments on commit 250d0a3

Please sign in to comment.