- d6b8d35be9659e1c99a5daca1af8c8587acaa044 Update bazel_toolchains to the latest commit. by Abseil Team <absl-team@google.com>

- 38311bf46f29bf1b20bdfe6c9b10c54e6258d28c Fix inlined_vector_benchmark when using libc++. libc++'s ... by Derek Mauro <dmauro@google.com>
  - 32178d067d4af7c3062532103d213eb7230c2be6 Adding sha256 hashes to dependencies in Abseil OSS WORKSP... by Daniel Katz <katzdm@google.com>
  - 13ac34416b326909f1ce0889ec0eb3bff3f3bebe Fix silly whitespace typo. by Daniel Katz <katzdm@google.com>

GitOrigin-RevId: d6b8d35be9659e1c99a5daca1af8c8587acaa044
Change-Id: I6be0d76930206edb79a10779bff3ffcc5ce856c9
pull/134/head
Abseil Team 7 years ago committed by Gennadiy Rozental
parent eb686c069f
commit f44e1eed08
  1. 17
      WORKSPACE
  2. 4
      absl/base/internal/identity.h
  3. 37
      absl/container/inlined_vector_benchmark.cc

@ -1,13 +1,13 @@
workspace(name = "com_google_absl")
# Bazel toolchains
http_archive(
name = "bazel_toolchains",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/f8847f64e6950e8ab9fde1c0aba768550b0d9ab2.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/f8847f64e6950e8ab9fde1c0aba768550b0d9ab2.tar.gz",
],
strip_prefix = "bazel-toolchains-f8847f64e6950e8ab9fde1c0aba768550b0d9ab2",
sha256 = "794366f51fea224b3656a0b0f8f1518e739748646523a572fcd3d68614a0e670",
name = "bazel_toolchains",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/2cec6c9f6d12224e93d9b3f337b24e41602de3ba.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/2cec6c9f6d12224e93d9b3f337b24e41602de3ba.tar.gz",
],
strip_prefix = "bazel-toolchains-2cec6c9f6d12224e93d9b3f337b24e41602de3ba",
sha256 = "9b8d85b61d8945422e86ac31e4d4d2d967542c080d1da1b45364da7fd6bdd638",
)
# GoogleTest/GoogleMock framework. Used by most unit-tests.
@ -15,6 +15,7 @@ http_archive(
name = "com_google_googletest",
urls = ["https://github.com/google/googletest/archive/4e4df226fc197c0dda6e37f5c8c3845ca1e73a49.zip"],
strip_prefix = "googletest-4e4df226fc197c0dda6e37f5c8c3845ca1e73a49",
sha256 = "d4179caf54410968d1fff0b869e7d74803dd30209ee6645ccf1ca65ab6cf5e5a",
)
# Google benchmark.
@ -22,6 +23,7 @@ http_archive(
name = "com_github_google_benchmark",
urls = ["https://github.com/google/benchmark/archive/16703ff83c1ae6d53e5155df3bb3ab0bc96083be.zip"],
strip_prefix = "benchmark-16703ff83c1ae6d53e5155df3bb3ab0bc96083be",
sha256 = "59f918c8ccd4d74b6ac43484467b500f1d64b40cc1010daa055375b322a43ba3",
)
# RE2 regular-expression framework. Used by some unit-tests.
@ -29,4 +31,5 @@ http_archive(
name = "com_googlesource_code_re2",
urls = ["https://github.com/google/re2/archive/6cf8ccd82dbaab2668e9b13596c68183c9ecd13f.zip"],
strip_prefix = "re2-6cf8ccd82dbaab2668e9b13596c68183c9ecd13f",
sha256 = "279a852219dbfc504501775596089d30e9c0b29664ce4128b0ac4c841471a16a",
)

@ -27,7 +27,7 @@ struct identity {
template <typename T>
using identity_t = typename identity<T>::type;
} // namespace internal
} // namespace absl
} // namespace internal
} // namespace absl
#endif // ABSL_BASE_INTERNAL_IDENTITY_H_

@ -63,18 +63,34 @@ void BM_StdVectorFill(benchmark::State& state) {
}
BENCHMARK(BM_StdVectorFill)->Range(0, 1024);
// The purpose of the next two benchmarks is to verify that
// absl::InlinedVector is efficient when moving is more efficent than
// copying. To do so, we use strings that are larger than the short
// std::string optimization.
bool StringRepresentedInline(std::string s) {
const char* chars = s.data();
std::string s1 = std::move(s);
return s1.data() != chars;
}
int GetNonShortStringOptimizationSize() {
for (int i = 24; i <= 192; i *= 2) {
if (!StringRepresentedInline(std::string(i, 'A'))) {
return i;
}
}
ABSL_RAW_LOG(
FATAL,
"Failed to find a std::string larger than the short std::string optimization");
return -1;
}
void BM_InlinedVectorFillString(benchmark::State& state) {
const int len = state.range(0);
std::string strings[4] = {"a quite long string",
"another long string",
"012345678901234567",
"to cause allocation"};
const int no_sso = GetNonShortStringOptimizationSize();
std::string strings[4] = {std::string(no_sso, 'A'), std::string(no_sso, 'B'),
std::string(no_sso, 'C'), std::string(no_sso, 'D')};
for (auto _ : state) {
absl::InlinedVector<std::string, 8> v;
for (int i = 0; i < len; i++) {
@ -87,10 +103,10 @@ BENCHMARK(BM_InlinedVectorFillString)->Range(0, 1024);
void BM_StdVectorFillString(benchmark::State& state) {
const int len = state.range(0);
std::string strings[4] = {"a quite long string",
"another long string",
"012345678901234567",
"to cause allocation"};
const int no_sso = GetNonShortStringOptimizationSize();
std::string strings[4] = {std::string(no_sso, 'A'), std::string(no_sso, 'B'),
std::string(no_sso, 'C'), std::string(no_sso, 'D')};
for (auto _ : state) {
std::vector<std::string> v;
for (int i = 0; i < len; i++) {
@ -98,11 +114,6 @@ void BM_StdVectorFillString(benchmark::State& state) {
}
}
state.SetItemsProcessed(static_cast<int64_t>(state.iterations()) * len);
// The purpose of the benchmark is to verify that inlined vector is
// efficient when moving is more efficent than copying. To do so, we
// use strings that are larger than the small std::string optimization.
ABSL_RAW_CHECK(!StringRepresentedInline(strings[0]),
"benchmarked with strings that are too small");
}
BENCHMARK(BM_StdVectorFillString)->Range(0, 1024);

Loading…
Cancel
Save