cppgc: Add allocation benchmark
Output: $ out/x64.release/cppgc_allocation_benchmark --benchmark_repetitions=3 Running out/x64.release/cppgc_allocation_benchmark Run on (56 X 3500 MHz CPU s) CPU Caches: L1 Data 32 KiB (x28) L1 Instruction 32 KiB (x28) L2 Unified 256 KiB (x28) L3 Unified 35840 KiB (x2) Load Average: 0.23, 0.27, 0.27 -------------------------------------------------------------------------------- Benchmark Time CPU Iterations UserCounters... -------------------------------------------------------------------------------- Allocate/Tiny 17.0 ns 17.0 ns 40348381 bytes_per_second=55.9692M/s Allocate/Tiny 17.1 ns 17.1 ns 40348381 bytes_per_second=55.8961M/s Allocate/Tiny 17.2 ns 17.2 ns 40348381 bytes_per_second=55.3108M/s Allocate/Tiny_mean 17.1 ns 17.1 ns 3 bytes_per_second=55.7254M/s Allocate/Tiny_median 17.1 ns 17.1 ns 3 bytes_per_second=55.8961M/s Allocate/Tiny_stddev 0.112 ns 0.111 ns 3 bytes_per_second=369.571k/s Allocate/Large 40339 ns 40334 ns 17707 bytes_per_second=1.51326G/s Allocate/Large 40350 ns 40343 ns 17707 bytes_per_second=1.51292G/s Allocate/Large 40205 ns 40192 ns 17707 bytes_per_second=1.51861G/s Allocate/Large_mean 40298 ns 40290 ns 3 bytes_per_second=1.51493G/s Allocate/Large_median 40339 ns 40334 ns 3 bytes_per_second=1.51326G/s Allocate/Large_stddev 81.2 ns 84.7 ns 3 bytes_per_second=3.26614M/s 2020-07-03T09: 14:23+02:00 Change-Id: I25a55beb5ea1718af76e638b752bf7d67cfe373e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2280086 Reviewed-by: Anton Bikineev <bikineev@chromium.org> Reviewed-by: Omer Katz <omerkatz@chromium.org> Commit-Queue: Michael Lippautz <mlippautz@chromium.org> Cr-Commit-Position: refs/heads/master@{#68672}
This commit is contained in:
parent
a3de69daeb
commit
66fc94313b
@ -10,7 +10,10 @@ group("gn_all") {
|
||||
deps = []
|
||||
|
||||
if (v8_enable_google_benchmark) {
|
||||
deps += [ ":empty_benchmark" ]
|
||||
deps += [
|
||||
":empty_benchmark",
|
||||
"cppgc:gn_all",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
52
test/benchmarks/cpp/cppgc/BUILD.gn
Normal file
52
test/benchmarks/cpp/cppgc/BUILD.gn
Normal file
@ -0,0 +1,52 @@
|
||||
# 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 += [ ":cppgc_allocation_benchmark" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (v8_enable_google_benchmark) {
|
||||
v8_source_set("cppgc_benchmark_support") {
|
||||
testonly = true
|
||||
|
||||
configs = [
|
||||
"../../../..:external_config",
|
||||
"../../../..:internal_config_base",
|
||||
"../../../..:cppgc_base_config",
|
||||
]
|
||||
sources = [
|
||||
"../../../../test/unittests/heap/cppgc/test-platform.cc",
|
||||
"../../../../test/unittests/heap/cppgc/test-platform.h",
|
||||
"utils.h",
|
||||
]
|
||||
deps = [
|
||||
"../../../..:cppgc_for_testing",
|
||||
"//third_party/google_benchmark:benchmark_main",
|
||||
]
|
||||
}
|
||||
|
||||
v8_executable("cppgc_allocation_benchmark") {
|
||||
testonly = true
|
||||
|
||||
configs = [
|
||||
"../../../..:external_config",
|
||||
"../../../..:internal_config_base",
|
||||
"../../../..:cppgc_base_config",
|
||||
]
|
||||
sources = [ "allocation_perf.cc" ]
|
||||
deps = [
|
||||
":cppgc_benchmark_support",
|
||||
"../../../..:cppgc_for_testing",
|
||||
"//third_party/google_benchmark:benchmark_main",
|
||||
]
|
||||
}
|
||||
}
|
6
test/benchmarks/cpp/cppgc/DEPS
Normal file
6
test/benchmarks/cpp/cppgc/DEPS
Normal file
@ -0,0 +1,6 @@
|
||||
include_rules = [
|
||||
"+include/cppgc",
|
||||
"+src/heap/cppgc",
|
||||
"+test/unittests/heap/cppgc",
|
||||
"+third_party/google_benchmark/src/include/benchmark/benchmark.h",
|
||||
]
|
49
test/benchmarks/cpp/cppgc/allocation_perf.cc
Normal file
49
test/benchmarks/cpp/cppgc/allocation_perf.cc
Normal file
@ -0,0 +1,49 @@
|
||||
// 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 "include/cppgc/allocation.h"
|
||||
#include "include/cppgc/garbage-collected.h"
|
||||
#include "src/heap/cppgc/globals.h"
|
||||
#include "src/heap/cppgc/heap.h"
|
||||
#include "test/benchmarks/cpp/cppgc/utils.h"
|
||||
#include "third_party/google_benchmark/src/include/benchmark/benchmark.h"
|
||||
|
||||
namespace cppgc {
|
||||
namespace internal {
|
||||
namespace {
|
||||
|
||||
using Allocate = testing::BenchmarkWithHeap;
|
||||
|
||||
class TinyObject final : public cppgc::GarbageCollected<TinyObject> {
|
||||
public:
|
||||
void Trace(cppgc::Visitor*) const {}
|
||||
};
|
||||
|
||||
BENCHMARK_F(Allocate, Tiny)(benchmark::State& st) {
|
||||
Heap::NoGCScope no_gc(*Heap::From(&heap()));
|
||||
for (auto _ : st) {
|
||||
benchmark::DoNotOptimize(
|
||||
cppgc::MakeGarbageCollected<TinyObject>(heap().GetAllocationHandle()));
|
||||
}
|
||||
st.SetBytesProcessed(st.iterations() * sizeof(TinyObject));
|
||||
}
|
||||
|
||||
class LargeObject final : public GarbageCollected<LargeObject> {
|
||||
public:
|
||||
void Trace(cppgc::Visitor*) const {}
|
||||
char padding[kLargeObjectSizeThreshold + 1];
|
||||
};
|
||||
|
||||
BENCHMARK_F(Allocate, Large)(benchmark::State& st) {
|
||||
Heap::NoGCScope no_gc(*Heap::From(&heap()));
|
||||
for (auto _ : st) {
|
||||
benchmark::DoNotOptimize(
|
||||
cppgc::MakeGarbageCollected<LargeObject>(heap().GetAllocationHandle()));
|
||||
}
|
||||
st.SetBytesProcessed(st.iterations() * sizeof(LargeObject));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace internal
|
||||
} // namespace cppgc
|
41
test/benchmarks/cpp/cppgc/utils.h
Normal file
41
test/benchmarks/cpp/cppgc/utils.h
Normal file
@ -0,0 +1,41 @@
|
||||
// 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.
|
||||
|
||||
#ifndef TEST_BENCHMARK_CPP_CPPGC_UTILS_H_
|
||||
#define TEST_BENCHMARK_CPP_CPPGC_UTILS_H_
|
||||
|
||||
#include "include/cppgc/heap.h"
|
||||
#include "include/cppgc/platform.h"
|
||||
#include "test/unittests/heap/cppgc/test-platform.h"
|
||||
#include "third_party/google_benchmark/src/include/benchmark/benchmark.h"
|
||||
|
||||
namespace cppgc {
|
||||
namespace internal {
|
||||
namespace testing {
|
||||
|
||||
class BenchmarkWithHeap : public benchmark::Fixture {
|
||||
protected:
|
||||
void SetUp(const ::benchmark::State& state) override {
|
||||
platform_ = std::make_shared<testing::TestPlatform>();
|
||||
cppgc::InitializeProcess(platform_->GetPageAllocator());
|
||||
heap_ = cppgc::Heap::Create(platform_);
|
||||
}
|
||||
|
||||
void TearDown(const ::benchmark::State& state) override {
|
||||
heap_.reset();
|
||||
cppgc::ShutdownProcess();
|
||||
}
|
||||
|
||||
cppgc::Heap& heap() const { return *heap_.get(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<testing::TestPlatform> platform_;
|
||||
std::unique_ptr<cppgc::Heap> heap_;
|
||||
};
|
||||
|
||||
} // namespace testing
|
||||
} // namespace internal
|
||||
} // namespace cppgc
|
||||
|
||||
#endif // TEST_BENCHMARK_CPP_CPPGC_UTILS_H_
|
Loading…
Reference in New Issue
Block a user