Skip to content

Commit

Permalink
perf_hooks: import http2 only once
Browse files Browse the repository at this point in the history
Import http2 internal bindings on each collectHttp2Stats call is not
required.

PR-URL: #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>
  • Loading branch information
fanatid authored and targos committed Sep 20, 2019
1 parent 844b45b commit b30c40b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b30c40b

Please sign in to comment.