Add google_benchmark depdendency

This adds Google benchmark for microbenchmarking C++ code as an
optional dependency.

To enable, add the following to the .gclient before syncing
  "custom_vars": {
      "checkout_google_benchmark": True
  }

Change-Id: Id0eab772dd71558906658ef4bb60e31acd665948
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2275964
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68663}
This commit is contained in:
Michael Lippautz 2020-07-02 20:24:48 +02:00 committed by Commit Bot
parent 458702f95a
commit b804266f72
9 changed files with 150 additions and 0 deletions

7
DEPS
View File

@ -4,6 +4,7 @@
gclient_gn_args_file = 'v8/build/config/gclient_args.gni'
gclient_gn_args = [
'checkout_google_benchmark',
'mac_xcode_version',
]
@ -33,6 +34,8 @@ vars = {
'download_jsfunfuzz': False,
'check_v8_header_includes': False,
'checkout_google_benchmark' : False,
'mac_xcode_version': 'default',
# GN CIPD package version.
@ -186,6 +189,10 @@ deps = {
},
'v8/third_party/googletest/src':
Var('chromium_url') + '/external/github.com/google/googletest.git' + '@' + '4fe018038f87675c083d0cfb6a6b57c274fb1753',
'v8/third_party/google_benchmark/src': {
'url': Var('chromium_url') + '/external/github.com/google/benchmark.git' + '@' + '7f27afe83b82f3a98baf58ef595814b9d42a5b2b',
'condition': 'checkout_google_benchmark',
},
'v8/third_party/jinja2':
Var('chromium_url') + '/chromium/src/third_party/jinja2.git' + '@' + '3f90fa05c85718505e28c9c3426c1ba52843b9b7',
'v8/third_party/markupsafe':

View File

@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/gclient_args.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/config/v8_target_cpu.gni")
import("split_static_library.gni")
@ -65,6 +66,8 @@ declare_args() {
# Add fuzzilli fuzzer support.
v8_fuzzilli = false
v8_enable_google_benchmark = checkout_google_benchmark
}
if (v8_use_external_startup_data == "") {

View File

@ -33,6 +33,7 @@ group("gn_all") {
if (host_os != "mac" || !is_android) {
# These items don't compile for Android on Mac.
deps += [
"benchmarks/cpp:gn_all",
"cctest:cctest",
"cctest:generate-bytecode-expectations",
"unittests:unittests",

View File

@ -0,0 +1,27 @@
# Copyright 2020 The V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("../../../gni/v8.gni")
group("gn_all") {
testonly = true
deps = []
if (v8_enable_google_benchmark) {
deps += [ ":empty_benchmark" ]
}
}
if (v8_enable_google_benchmark) {
v8_executable("empty_benchmark") {
testonly = true
configs = []
sources = [ "empty.cc" ]
deps = [ "//third_party/google_benchmark:benchmark_main" ]
}
}

3
test/benchmarks/cpp/DEPS Normal file
View File

@ -0,0 +1,3 @@
include_rules = [
"+third_party/google_benchmark/src/include/benchmark/benchmark.h",
]

View File

@ -0,0 +1,12 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/google_benchmark/src/include/benchmark/benchmark.h"
static void BM_Empty(benchmark::State& state) {
for (auto _ : state) {
}
}
// Register the function as a benchmark
BENCHMARK(BM_Empty);

73
third_party/google_benchmark/BUILD.gn vendored Normal file
View File

@ -0,0 +1,73 @@
# Copyright 2020 The V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/gclient_args.gni")
if (checkout_google_benchmark) {
config("benchmark_config") {
include_dirs = [ "src/include" ]
}
source_set("google_benchmark") {
testonly = true
public = [ "src/include/benchmark/benchmark.h" ]
sources = [
"src/src/arraysize.h",
"src/src/benchmark.cc",
"src/src/benchmark_api_internal.cc",
"src/src/benchmark_api_internal.h",
"src/src/benchmark_name.cc",
"src/src/benchmark_register.cc",
"src/src/benchmark_register.h",
"src/src/benchmark_runner.cc",
"src/src/benchmark_runner.h",
"src/src/check.h",
"src/src/colorprint.cc",
"src/src/colorprint.h",
"src/src/commandlineflags.cc",
"src/src/commandlineflags.h",
"src/src/complexity.cc",
"src/src/complexity.h",
"src/src/console_reporter.cc",
"src/src/counter.cc",
"src/src/counter.h",
"src/src/csv_reporter.cc",
"src/src/cycle_clock.h",
"src/src/internal_macros.h",
"src/src/json_reporter.cc",
"src/src/log.h",
"src/src/mutex.h",
"src/src/re.h",
"src/src/reporter.cc",
"src/src/sleep.cc",
"src/src/sleep.h",
"src/src/statistics.cc",
"src/src/statistics.h",
"src/src/string_util.cc",
"src/src/string_util.h",
"src/src/sysinfo.cc",
"src/src/thread_manager.h",
"src/src/thread_timer.h",
"src/src/timers.cc",
"src/src/timers.h",
]
all_dependent_configs = [ ":benchmark_config" ]
defines = [
# Tell google_benchmark to always use standard regular expressions.
"HAVE_GNU_POSIX_REGEX=0",
"HAVE_POSIX_REGEX=0",
"HAVE_STD_REGEX=1",
]
}
source_set("benchmark_main") {
testonly = true
sources = [ "src/src/benchmark_main.cc" ]
deps = [ ":google_benchmark" ]
}
}

3
third_party/google_benchmark/OWNERS vendored Normal file
View File

@ -0,0 +1,3 @@
file:../../INFRA_OWNERS
mlippautz@chromium.org

21
third_party/google_benchmark/README.v8 vendored Normal file
View File

@ -0,0 +1,21 @@
Name: Google Benchmark
Short Name: benchmark
URL: https://github.com/google/benchmark
Version: unknown
License: Apache 2.0
License File: NOT_SHIPPED
Security Critical: no
Description:
A microbenchmark support library.
To include this library in the V8 checkout, add the following clause to
your .gclient configuration.
"custom_vars": {
"checkout_google_benchmark": True,
}
Local Additions:
* gn file for building in V8