Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafaelGSS <rafael.nunu@hotmail.com>2022-04-10 05:37:03 +0300
committerMichaƫl Zasso <targos@protonmail.com>2022-07-31 10:44:10 +0300
commit6dcdcd7f5040f6436da6a3cce9ea2476ccc73b67 (patch)
tree603fb62cfb03b65552bfccc185c416eb9b58ebfc /benchmark
parent0eb8c46db6561b52c435bef41ae25ae831924bb8 (diff)
perf_hooks: add PerformanceResourceTiming
perf_hooks: create clearResourceTimings perf_hooks: add resourcetiming test parallel perf_hooks: add markResourceTiming perf_hooks: fix observable when using resource perf_hooks: fix observable when using resource perf_hooks: add class comments perf_hooks: add PerformanceResourceTiming perf_hooks: create clearResourceTimings perf_hooks: add resourcetiming test parallel perf_hooks: add markResourceTiming perf_hooks: fix observable when using resource perf_hooks: fix observable when using resource perf_hooks: add class comments perf_hooks: add Resource Timing documentation benchmark: measure resource timing module perf_hooks: add check avoiding new PerformanceResourceTiming perf_hooks: adjust doc PR-URL: https://github.com/nodejs/node/pull/42725 Fixes: https://github.com/nodejs/undici/issues/952 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/perf_hooks/resourcetiming.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/benchmark/perf_hooks/resourcetiming.js b/benchmark/perf_hooks/resourcetiming.js
new file mode 100644
index 00000000000..c71cfeae7ef
--- /dev/null
+++ b/benchmark/perf_hooks/resourcetiming.js
@@ -0,0 +1,77 @@
+'use strict';
+
+const common = require('../common.js');
+
+const {
+ PerformanceObserver,
+ performance,
+} = require('perf_hooks');
+
+function createTimingInfo({
+ startTime = 0,
+ redirectStartTime = 0,
+ redirectEndTime = 0,
+ postRedirectStartTime = 0,
+ finalServiceWorkerStartTime = 0,
+ finalNetworkRequestStartTime = 0,
+ finalNetworkResponseStartTime = 0,
+ endTime = 0,
+ encodedBodySize = 0,
+ decodedBodySize = 0,
+ finalConnectionTimingInfo = null
+}) {
+ if (finalConnectionTimingInfo !== null) {
+ finalConnectionTimingInfo.domainLookupStartTime =
+ finalConnectionTimingInfo.domainLookupStartTime || 0;
+ finalConnectionTimingInfo.domainLookupEndTime =
+ finalConnectionTimingInfo.domainLookupEndTime || 0;
+ finalConnectionTimingInfo.connectionStartTime =
+ finalConnectionTimingInfo.connectionStartTime || 0;
+ finalConnectionTimingInfo.connectionEndTime =
+ finalConnectionTimingInfo.connectionEndTime || 0;
+ finalConnectionTimingInfo.secureConnectionStartTime =
+ finalConnectionTimingInfo.secureConnectionStartTime || 0;
+ finalConnectionTimingInfo.ALPNNegotiatedProtocol =
+ finalConnectionTimingInfo.ALPNNegotiatedProtocol || [];
+ }
+ return {
+ startTime,
+ redirectStartTime,
+ redirectEndTime,
+ postRedirectStartTime,
+ finalServiceWorkerStartTime,
+ finalNetworkRequestStartTime,
+ finalNetworkResponseStartTime,
+ endTime,
+ encodedBodySize,
+ decodedBodySize,
+ finalConnectionTimingInfo,
+ };
+}
+
+const bench = common.createBenchmark(main, {
+ n: [1e5],
+ observe: ['resource'],
+});
+
+function test() {
+ const timingInfo = createTimingInfo({ finalConnectionTimingInfo: {} });
+ performance.markResourceTiming(
+ timingInfo,
+ 'http://localhost:8080',
+ 'fetch',
+ {},
+ ''
+ );
+}
+
+function main({ n, observe }) {
+ const obs = new PerformanceObserver(() => {
+ bench.end(n);
+ });
+ obs.observe({ entryTypes: [observe], buffered: true });
+
+ bench.start();
+ for (let i = 0; i < 1e5; i++)
+ test();
+}