diff --git a/test/benchmarks/cpp/BUILD.gn b/test/benchmarks/cpp/BUILD.gn index 4507946e23..6c57952841 100644 --- a/test/benchmarks/cpp/BUILD.gn +++ b/test/benchmarks/cpp/BUILD.gn @@ -9,7 +9,7 @@ group("gn_all") { deps = [] - if (v8_enable_google_benchmark && !is_win) { + if (v8_enable_google_benchmark) { deps += [ ":empty_benchmark", "cppgc:gn_all", @@ -17,7 +17,7 @@ group("gn_all") { } } -if (v8_enable_google_benchmark && !is_win) { +if (v8_enable_google_benchmark) { v8_executable("empty_benchmark") { testonly = true diff --git a/test/benchmarks/cpp/DEPS b/test/benchmarks/cpp/DEPS index fdb90962fa..05d243bc85 100644 --- a/test/benchmarks/cpp/DEPS +++ b/test/benchmarks/cpp/DEPS @@ -1,3 +1,4 @@ include_rules = [ + "+src/base", "+third_party/google_benchmark/src/include/benchmark/benchmark.h", ] diff --git a/test/benchmarks/cpp/cppgc/BUILD.gn b/test/benchmarks/cpp/cppgc/BUILD.gn index 2d63145aba..c9ba5fa7b9 100644 --- a/test/benchmarks/cpp/cppgc/BUILD.gn +++ b/test/benchmarks/cpp/cppgc/BUILD.gn @@ -9,12 +9,12 @@ group("gn_all") { deps = [] - if (v8_enable_google_benchmark && !is_win) { + if (v8_enable_google_benchmark) { deps += [ ":cppgc_basic_benchmarks" ] } } -if (v8_enable_google_benchmark && !is_win) { +if (v8_enable_google_benchmark) { v8_source_set("cppgc_benchmark_support") { testonly = true diff --git a/test/benchmarks/cpp/cppgc/DEPS b/test/benchmarks/cpp/cppgc/DEPS index d31d529ebe..e3cbedf197 100644 --- a/test/benchmarks/cpp/cppgc/DEPS +++ b/test/benchmarks/cpp/cppgc/DEPS @@ -1,5 +1,6 @@ include_rules = [ "+include/cppgc", + "+src/base", "+src/heap/cppgc", "+test/unittests/heap/cppgc", "+third_party/google_benchmark/src/include/benchmark/benchmark.h", diff --git a/test/benchmarks/cpp/cppgc/allocation_perf.cc b/test/benchmarks/cpp/cppgc/allocation_perf.cc index 513aaa2e8e..804e11770a 100644 --- a/test/benchmarks/cpp/cppgc/allocation_perf.cc +++ b/test/benchmarks/cpp/cppgc/allocation_perf.cc @@ -5,6 +5,7 @@ #include "include/cppgc/allocation.h" #include "include/cppgc/garbage-collected.h" #include "include/cppgc/heap-consistency.h" +#include "src/base/macros.h" #include "src/heap/cppgc/globals.h" #include "src/heap/cppgc/heap.h" #include "test/benchmarks/cpp/cppgc/utils.h" @@ -24,6 +25,7 @@ class TinyObject final : public cppgc::GarbageCollected { BENCHMARK_F(Allocate, Tiny)(benchmark::State& st) { subtle::NoGarbageCollectionScope no_gc(*Heap::From(&heap())); for (auto _ : st) { + USE(_); benchmark::DoNotOptimize( cppgc::MakeGarbageCollected(heap().GetAllocationHandle())); } @@ -39,6 +41,7 @@ class LargeObject final : public GarbageCollected { BENCHMARK_F(Allocate, Large)(benchmark::State& st) { subtle::NoGarbageCollectionScope no_gc(*Heap::From(&heap())); for (auto _ : st) { + USE(_); benchmark::DoNotOptimize( cppgc::MakeGarbageCollected(heap().GetAllocationHandle())); } diff --git a/test/benchmarks/cpp/cppgc/trace_perf.cc b/test/benchmarks/cpp/cppgc/trace_perf.cc index c474d58560..6038c0a371 100644 --- a/test/benchmarks/cpp/cppgc/trace_perf.cc +++ b/test/benchmarks/cpp/cppgc/trace_perf.cc @@ -5,6 +5,7 @@ #include "include/cppgc/allocation.h" #include "include/cppgc/garbage-collected.h" #include "include/cppgc/persistent.h" +#include "src/base/macros.h" #include "src/heap/cppgc/globals.h" #include "src/heap/cppgc/heap.h" #include "test/benchmarks/cpp/cppgc/utils.h" @@ -65,6 +66,7 @@ BENCHMARK_F(Trace, Static)(benchmark::State& st) { heap().GetAllocationHandle()))); VisitorBase visitor; for (auto _ : st) { + USE(_); DispatchTrace(&visitor, holder->base_ref); } } @@ -75,6 +77,7 @@ BENCHMARK_F(Trace, Dynamic)(benchmark::State& st) { heap().GetAllocationHandle()))); VisitorBase visitor; for (auto _ : st) { + USE(_); DispatchTrace(&visitor, holder->mixin_ref); } } diff --git a/test/benchmarks/cpp/empty.cc b/test/benchmarks/cpp/empty.cc index 26c73604a4..f15f04fcd7 100644 --- a/test/benchmarks/cpp/empty.cc +++ b/test/benchmarks/cpp/empty.cc @@ -2,11 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/base/macros.h" #include "third_party/google_benchmark/src/include/benchmark/benchmark.h" static void BM_Empty(benchmark::State& state) { for (auto _ : state) { + USE(_); } } -// Register the function as a benchmark + +// Register the function as a benchmark. The empty benchmark ensures that the +// framework compiles and links as expected. BENCHMARK(BM_Empty);