Skip to content

Commit 89dfeb6

Browse files
committed
[Squash] Testing
1 parent e5ddf5b commit 89dfeb6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/perf_hooks.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ const {
3636
NODE_PERFORMANCE_MILESTONE_PRELOAD_MODULE_LOAD_END
3737
} = constants;
3838

39-
const { sessionStats, streamStats } = process.binding('http2');
40-
4139
const L = require('internal/linkedlist');
4240
const kInspect = require('internal/util').customInspectSymbol;
4341
const { inherits } = require('util');
@@ -85,9 +83,14 @@ const IDX_SESSION_STATS_DATA_SENT = 6;
8583
const IDX_SESSION_STATS_DATA_RECEIVED = 7;
8684
const IDX_SESSION_STATS_MAX_CONCURRENT_STREAMS = 8;
8785

86+
let sessionStats;
87+
let streamStats;
88+
8889
function collectHttp2Stats(entry) {
8990
switch (entry.name) {
9091
case 'Http2Stream':
92+
if (streamStats === undefined)
93+
streamStats = process.binding('http2').streamStats;
9194
entry.id =
9295
streamStats[IDX_STREAM_STATS_ID] >>> 0;
9396
entry.timeToFirstByte =
@@ -102,6 +105,8 @@ function collectHttp2Stats(entry) {
102105
streamStats[IDX_STREAM_STATS_RECEIVEDBYTES];
103106
break;
104107
case 'Http2Session':
108+
if (sessionStats === undefined)
109+
sessionStats = process.binding('http2').sessionStats;
105110
entry.type =
106111
sessionStats[IDX_SESSION_STATS_TYPE] >>> 0 === 0 ? 'server' : 'client';
107112
entry.pingRTT =

0 commit comments

Comments
 (0)