From ecf2434c34f6d37188c51e8fccf67b6d1f04ecf0 Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Tue, 3 Sep 2019 14:00:33 +0300 Subject: [PATCH] perf_hooks: import http2 only once Import http2 internal bindings on each collectHttp2Stats call is not required. --- lib/perf_hooks.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 14b1aa44dddc26..453fc54eb95132 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -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)