mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 19:48:12 +00:00

PR-URL: https://github.com/nodejs/node/pull/54077 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
42 lines
1.3 KiB
C++
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_
|