blob: c44eda0235e241c26bbb8340778f17e68cc7a40b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
<!DOCTYPE html>
<!--
Copyright 2021 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/tracing/extras/chrome/event_finder_utils.html">
<link rel="import" href="/tracing/metrics/metric_registry.html">
<script>
'use strict';
/**
* This metric is used for for blink network metrics
* - blinkRequestResourceCount: the count of requested resources
*/
tr.exportTo('tr.metrics', function() {
function blinkResourceMetric(histograms, model, opt_options) {
const chromeHelper = model.getOrCreateHelper(
tr.model.helpers.ChromeModelHelper);
if (!chromeHelper) {
// Chrome isn't present.
return;
}
const CATEGORY = 'blink';
const NAME = 'ResourceFetcher::requestResource';
let count = 0;
// Collect trace events.
for (const helper of Object.values(chromeHelper.rendererHelpers)) {
if (helper.isChromeTracingUI) continue;
const events = tr.e.chrome.EventFinderUtils.getMainThreadEvents(
helper, NAME, CATEGORY);
for (const event of events) {
count++;
}
}
// Generate histograms.
histograms.createHistogram(
'blinkRequestResourceCount', tr.b.Unit.byName.count, count);
}
tr.metrics.MetricRegistry.register(blinkResourceMetric, {
supportsRangeOfInterest: false,
});
return {
blinkResourceMetric,
};
});
</script>
|