From b30c40bd5df6ff6bbc166ad217a49d9f047c0a74 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. PR-URL: https://github.com/nodejs/node/pull/29419 Reviewed-By: Colin Ihrig Reviewed-By: David Carlier Reviewed-By: Trivikram Kamat Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Minwoo Jung --- 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)