implement perf_hooks.constants (#3476)

This commit is contained in:
dave caruso
2023-06-30 17:58:38 -04:00
committed by GitHub
parent b83faf8018
commit d356cd5d48
2 changed files with 28 additions and 13 deletions

View File

@@ -452,19 +452,19 @@ declare module "perf_hooks" {
// },
// ): void;
// }
// namespace constants {
// const NODE_PERFORMANCE_GC_MAJOR: number;
// const NODE_PERFORMANCE_GC_MINOR: number;
// const NODE_PERFORMANCE_GC_INCREMENTAL: number;
// const NODE_PERFORMANCE_GC_WEAKCB: number;
// const NODE_PERFORMANCE_GC_FLAGS_NO: number;
// const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
// const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
// const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
// const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
// const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
// const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
// }
namespace constants {
const NODE_PERFORMANCE_GC_MAJOR: number;
const NODE_PERFORMANCE_GC_MINOR: number;
const NODE_PERFORMANCE_GC_INCREMENTAL: number;
const NODE_PERFORMANCE_GC_WEAKCB: number;
const NODE_PERFORMANCE_GC_FLAGS_NO: number;
const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
const NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: number;
const NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: number;
const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
}
const performance: Performance;
// interface EventLoopMonitorOptions {
// /**

View File

@@ -1,6 +1,20 @@
// Hardcoded module "node:perf_hooks"
import { throwNotImplemented } from "../shared";
export var constants = {
NODE_PERFORMANCE_GC_MAJOR: 4,
NODE_PERFORMANCE_GC_MINOR: 1,
NODE_PERFORMANCE_GC_INCREMENTAL: 8,
NODE_PERFORMANCE_GC_WEAKCB: 16,
NODE_PERFORMANCE_GC_FLAGS_NO: 0,
NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: 2,
NODE_PERFORMANCE_GC_FLAGS_FORCED: 4,
NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING: 8,
NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE: 16,
NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: 32,
NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: 64,
};
export var performance = globalThis.performance;
export class PerformanceObserver {
@@ -22,6 +36,7 @@ export class PerformanceNodeTiming {
export default {
performance,
constants,
PerformanceEntry,
PerformanceNodeTiming,
[Symbol.for("CommonJS")]: 0,