11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst { 41cb0ef41Sopenharmony_ci ObjectDefineProperties, 51cb0ef41Sopenharmony_ci ObjectSetPrototypeOf, 61cb0ef41Sopenharmony_ci} = primordials; 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst { PerformanceEntry } = require('internal/perf/performance_entry'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst { 111cb0ef41Sopenharmony_ci now, 121cb0ef41Sopenharmony_ci getMilestoneTimestamp, 131cb0ef41Sopenharmony_ci} = require('internal/perf/utils'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst { 161cb0ef41Sopenharmony_ci customInspectSymbol: kInspect, 171cb0ef41Sopenharmony_ci} = require('internal/util'); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ciconst { inspect } = require('util'); 201cb0ef41Sopenharmony_ci 211cb0ef41Sopenharmony_ciconst { 221cb0ef41Sopenharmony_ci constants: { 231cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_NODE_START, 241cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_V8_START, 251cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_LOOP_START, 261cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_LOOP_EXIT, 271cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE, 281cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_ENVIRONMENT, 291cb0ef41Sopenharmony_ci }, 301cb0ef41Sopenharmony_ci loopIdleTime, 311cb0ef41Sopenharmony_ci} = internalBinding('performance'); 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ciclass PerformanceNodeTiming { 341cb0ef41Sopenharmony_ci constructor() { 351cb0ef41Sopenharmony_ci ObjectDefineProperties(this, { 361cb0ef41Sopenharmony_ci name: { 371cb0ef41Sopenharmony_ci __proto__: null, 381cb0ef41Sopenharmony_ci enumerable: true, 391cb0ef41Sopenharmony_ci configurable: true, 401cb0ef41Sopenharmony_ci value: 'node', 411cb0ef41Sopenharmony_ci }, 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci entryType: { 441cb0ef41Sopenharmony_ci __proto__: null, 451cb0ef41Sopenharmony_ci enumerable: true, 461cb0ef41Sopenharmony_ci configurable: true, 471cb0ef41Sopenharmony_ci value: 'node', 481cb0ef41Sopenharmony_ci }, 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci startTime: { 511cb0ef41Sopenharmony_ci __proto__: null, 521cb0ef41Sopenharmony_ci enumerable: true, 531cb0ef41Sopenharmony_ci configurable: true, 541cb0ef41Sopenharmony_ci value: 0, 551cb0ef41Sopenharmony_ci }, 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci duration: { 581cb0ef41Sopenharmony_ci __proto__: null, 591cb0ef41Sopenharmony_ci enumerable: true, 601cb0ef41Sopenharmony_ci configurable: true, 611cb0ef41Sopenharmony_ci get: now, 621cb0ef41Sopenharmony_ci }, 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ci nodeStart: { 651cb0ef41Sopenharmony_ci __proto__: null, 661cb0ef41Sopenharmony_ci enumerable: true, 671cb0ef41Sopenharmony_ci configurable: true, 681cb0ef41Sopenharmony_ci get() { 691cb0ef41Sopenharmony_ci return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_NODE_START); 701cb0ef41Sopenharmony_ci }, 711cb0ef41Sopenharmony_ci }, 721cb0ef41Sopenharmony_ci 731cb0ef41Sopenharmony_ci v8Start: { 741cb0ef41Sopenharmony_ci __proto__: null, 751cb0ef41Sopenharmony_ci enumerable: true, 761cb0ef41Sopenharmony_ci configurable: true, 771cb0ef41Sopenharmony_ci get() { 781cb0ef41Sopenharmony_ci return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_V8_START); 791cb0ef41Sopenharmony_ci }, 801cb0ef41Sopenharmony_ci }, 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci environment: { 831cb0ef41Sopenharmony_ci __proto__: null, 841cb0ef41Sopenharmony_ci enumerable: true, 851cb0ef41Sopenharmony_ci configurable: true, 861cb0ef41Sopenharmony_ci get() { 871cb0ef41Sopenharmony_ci return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_ENVIRONMENT); 881cb0ef41Sopenharmony_ci }, 891cb0ef41Sopenharmony_ci }, 901cb0ef41Sopenharmony_ci 911cb0ef41Sopenharmony_ci loopStart: { 921cb0ef41Sopenharmony_ci __proto__: null, 931cb0ef41Sopenharmony_ci enumerable: true, 941cb0ef41Sopenharmony_ci configurable: true, 951cb0ef41Sopenharmony_ci get() { 961cb0ef41Sopenharmony_ci return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_LOOP_START); 971cb0ef41Sopenharmony_ci }, 981cb0ef41Sopenharmony_ci }, 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_ci loopExit: { 1011cb0ef41Sopenharmony_ci __proto__: null, 1021cb0ef41Sopenharmony_ci enumerable: true, 1031cb0ef41Sopenharmony_ci configurable: true, 1041cb0ef41Sopenharmony_ci get() { 1051cb0ef41Sopenharmony_ci return getMilestoneTimestamp(NODE_PERFORMANCE_MILESTONE_LOOP_EXIT); 1061cb0ef41Sopenharmony_ci }, 1071cb0ef41Sopenharmony_ci }, 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ci bootstrapComplete: { 1101cb0ef41Sopenharmony_ci __proto__: null, 1111cb0ef41Sopenharmony_ci enumerable: true, 1121cb0ef41Sopenharmony_ci configurable: true, 1131cb0ef41Sopenharmony_ci get() { 1141cb0ef41Sopenharmony_ci return getMilestoneTimestamp( 1151cb0ef41Sopenharmony_ci NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); 1161cb0ef41Sopenharmony_ci }, 1171cb0ef41Sopenharmony_ci }, 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci idleTime: { 1201cb0ef41Sopenharmony_ci __proto__: null, 1211cb0ef41Sopenharmony_ci enumerable: true, 1221cb0ef41Sopenharmony_ci configurable: true, 1231cb0ef41Sopenharmony_ci get: loopIdleTime, 1241cb0ef41Sopenharmony_ci }, 1251cb0ef41Sopenharmony_ci }); 1261cb0ef41Sopenharmony_ci } 1271cb0ef41Sopenharmony_ci 1281cb0ef41Sopenharmony_ci [kInspect](depth, options) { 1291cb0ef41Sopenharmony_ci if (depth < 0) return this; 1301cb0ef41Sopenharmony_ci 1311cb0ef41Sopenharmony_ci const opts = { 1321cb0ef41Sopenharmony_ci ...options, 1331cb0ef41Sopenharmony_ci depth: options.depth == null ? null : options.depth - 1, 1341cb0ef41Sopenharmony_ci }; 1351cb0ef41Sopenharmony_ci 1361cb0ef41Sopenharmony_ci return `PerformanceNodeTiming ${inspect(this.toJSON(), opts)}`; 1371cb0ef41Sopenharmony_ci } 1381cb0ef41Sopenharmony_ci 1391cb0ef41Sopenharmony_ci toJSON() { 1401cb0ef41Sopenharmony_ci return { 1411cb0ef41Sopenharmony_ci name: 'node', 1421cb0ef41Sopenharmony_ci entryType: 'node', 1431cb0ef41Sopenharmony_ci startTime: this.startTime, 1441cb0ef41Sopenharmony_ci duration: this.duration, 1451cb0ef41Sopenharmony_ci nodeStart: this.nodeStart, 1461cb0ef41Sopenharmony_ci v8Start: this.v8Start, 1471cb0ef41Sopenharmony_ci bootstrapComplete: this.bootstrapComplete, 1481cb0ef41Sopenharmony_ci environment: this.environment, 1491cb0ef41Sopenharmony_ci loopStart: this.loopStart, 1501cb0ef41Sopenharmony_ci loopExit: this.loopExit, 1511cb0ef41Sopenharmony_ci idleTime: this.idleTime, 1521cb0ef41Sopenharmony_ci }; 1531cb0ef41Sopenharmony_ci } 1541cb0ef41Sopenharmony_ci} 1551cb0ef41Sopenharmony_ci 1561cb0ef41Sopenharmony_ciObjectSetPrototypeOf( 1571cb0ef41Sopenharmony_ci PerformanceNodeTiming.prototype, 1581cb0ef41Sopenharmony_ci PerformanceEntry.prototype); 1591cb0ef41Sopenharmony_ci 1601cb0ef41Sopenharmony_cimodule.exports = new PerformanceNodeTiming(); 161