perf_hooks: import http2 only once

Import http2 internal bindings on each collectHttp2Stats call is not
required.

PR-URL: https://github.com/nodejs/node/pull/29419
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
This commit is contained in:
Kirill Fomichev 2019-09-03 14:00:33 +03:00 committed by Rich Trott
parent c6b7e748b0
commit 6186302654

View File

@ -92,11 +92,12 @@ const IDX_SESSION_STATS_DATA_SENT = 6;
const IDX_SESSION_STATS_DATA_RECEIVED = 7;
const IDX_SESSION_STATS_MAX_CONCURRENT_STREAMS = 8;
let http2;
let sessionStats;
let streamStats;
function collectHttp2Stats(entry) {
const http2 = internalBinding('http2');
if (http2 === undefined) http2 = internalBinding('http2');
switch (entry.name) {
case 'Http2Stream':
if (streamStats === undefined)