Files
v8/test/benchmarks/cpp/benchmark-utils.h
Michael Lippautz 9729069a16 Add benchmark for bindings operations
Adds a benchmark representing bindings setup.

Results:
------------------------------------------------------------------
Benchmark                                     Time             CPU
------------------------------------------------------------------
OldBindings/AccessorReturningWrapper    1510244 ns      1510078 ns
NewBindings/AccessorReturningWrapper    1248103 ns      1247787 ns
OldBindings/AccessorReturningSmi         622348 ns       622332 ns
NewBindings/AccessorReturningSmi         581722 ns       581705 ns

Bug: chromium:328117814
Change-Id: I6557a39b4c05c69e3751f6d0b7e172b29e47126c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5382158
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/main@{#93075}
2024-03-27 19:54:45 +00:00

42 lines
1.3 KiB
C++

// Copyright 2024 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_BENCHMARK_UTILS_H_
#define TEST_BENCHMARK_CPP_BENCHMARK_UTILS_H_
#include "include/v8-array-buffer.h"
#include "include/v8-cppgc.h"
#include "include/v8-isolate.h"
#include "include/v8-platform.h"
#include "third_party/google_benchmark_chrome/src/include/benchmark/benchmark.h"
namespace v8::benchmarking {
static constexpr uint16_t kEmbedderId = 0;
static constexpr size_t kTypeOffset = 0;
static constexpr size_t kInstanceOffset = 1;
// BenchmarkWithIsolate is a basic benchmark fixture that sets up the process
// with a single Isolate.
class BenchmarkWithIsolate : public benchmark::Fixture {
public:
static void InitializeProcess();
static void ShutdownProcess();
protected:
V8_INLINE v8::Isolate* v8_isolate() { return v8_isolate_; }
V8_INLINE cppgc::AllocationHandle& allocation_handle() {
return v8_isolate_->GetCppHeap()->GetAllocationHandle();
}
private:
static v8::Platform* platform_;
static v8::Isolate* v8_isolate_;
static v8::ArrayBuffer::Allocator* v8_ab_allocator_;
};
} // namespace v8::benchmarking
#endif // TEST_BENCHMARK_CPP_BENCHMARK_UTILS_H_