@atlaskit/editor-core 234.3.0 → 234.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/cjs/create-editor/editorNativeAnchorSupportPlugin.js +2 -7
- package/dist/cjs/presets/universal.js +1 -4
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +0 -1
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-compiled.js +3 -2
- package/dist/cjs/ui/Appearance/FullPage/FullPageContentArea-emotion.js +1 -25
- package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-compiled.compiled.css +1 -0
- package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-compiled.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/editorNativeAnchorSupportPlugin.js +2 -7
- package/dist/es2019/presets/universal.js +1 -4
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +0 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-compiled.js +3 -2
- package/dist/es2019/ui/Appearance/FullPage/FullPageContentArea-emotion.js +1 -25
- package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-compiled.compiled.css +1 -0
- package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-compiled.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/editorNativeAnchorSupportPlugin.js +2 -7
- package/dist/esm/presets/universal.js +1 -4
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.compiled.css +0 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-compiled.js +3 -2
- package/dist/esm/ui/Appearance/FullPage/FullPageContentArea-emotion.js +1 -25
- package/dist/esm/ui/EditorContentContainer/EditorContentContainer-compiled.compiled.css +1 -0
- package/dist/esm/ui/EditorContentContainer/EditorContentContainer-compiled.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/package.json +6 -6
- package/dist/cjs/utils/performance/outlier.js +0 -16
- package/dist/cjs/utils/performance/percentile.js +0 -22
- package/dist/cjs/utils/performance/plugin-performance-observer.js +0 -131
- package/dist/cjs/utils/performance/plugin-performance-report.js +0 -190
- package/dist/cjs/utils/performance/simple-measure-to-entries.js +0 -101
- package/dist/es2019/utils/performance/outlier.js +0 -10
- package/dist/es2019/utils/performance/percentile.js +0 -14
- package/dist/es2019/utils/performance/plugin-performance-observer.js +0 -88
- package/dist/es2019/utils/performance/plugin-performance-report.js +0 -133
- package/dist/es2019/utils/performance/simple-measure-to-entries.js +0 -83
- package/dist/esm/utils/performance/outlier.js +0 -10
- package/dist/esm/utils/performance/percentile.js +0 -16
- package/dist/esm/utils/performance/plugin-performance-observer.js +0 -124
- package/dist/esm/utils/performance/plugin-performance-report.js +0 -183
- package/dist/esm/utils/performance/simple-measure-to-entries.js +0 -94
- package/dist/types/utils/performance/outlier.d.ts +0 -1
- package/dist/types/utils/performance/percentile.d.ts +0 -1
- package/dist/types/utils/performance/plugin-performance-observer.d.ts +0 -23
- package/dist/types/utils/performance/plugin-performance-report.d.ts +0 -47
- package/dist/types/utils/performance/simple-measure-to-entries.d.ts +0 -28
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.SimpleMeasurementLogger = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _trackTransactions = require("./track-transactions");
|
|
13
|
-
var EVENT_NAMES = [_trackTransactions.EVENT_NAME_STATE_APPLY, _trackTransactions.EVENT_NAME_UPDATE_STATE, _trackTransactions.EVENT_NAME_VIEW_STATE_UPDATED, _trackTransactions.EVENT_NAME_ON_CHANGE, _trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* A class that logs and collates measurement entries until
|
|
17
|
-
* EVENT_NAME_DISPATCHTRANSACTION is detected.
|
|
18
|
-
*
|
|
19
|
-
* At that point, it will group together all the entries
|
|
20
|
-
* logged and fire a callback with all entries packaged
|
|
21
|
-
* into a PerformanceObserverEntryList.
|
|
22
|
-
*
|
|
23
|
-
* We are able to make use of this method as the measurements
|
|
24
|
-
* which occur during dispatchTransactions are synchronous.
|
|
25
|
-
*/
|
|
26
|
-
var SimpleMeasurementLogger = exports.SimpleMeasurementLogger = /*#__PURE__*/(0, _createClass2.default)(function SimpleMeasurementLogger() {
|
|
27
|
-
var _this = this;
|
|
28
|
-
(0, _classCallCheck2.default)(this, SimpleMeasurementLogger);
|
|
29
|
-
(0, _defineProperty2.default)(this, "currentBatch", []);
|
|
30
|
-
(0, _defineProperty2.default)(this, "pluginNameCache", new Set());
|
|
31
|
-
(0, _defineProperty2.default)(this, "setPluginNames", function (names) {
|
|
32
|
-
_this.pluginNameCache = new Set(names);
|
|
33
|
-
});
|
|
34
|
-
(0, _defineProperty2.default)(this, "setOnObservation", function (callback) {
|
|
35
|
-
_this.observationCallback = callback;
|
|
36
|
-
});
|
|
37
|
-
(0, _defineProperty2.default)(this, "createPerformanceEntry", function (reading) {
|
|
38
|
-
return {
|
|
39
|
-
entryType: 'mark',
|
|
40
|
-
name: reading.name,
|
|
41
|
-
startTime: reading.startTime,
|
|
42
|
-
duration: reading.duration,
|
|
43
|
-
toJSON: function toJSON() {
|
|
44
|
-
return JSON.stringify({
|
|
45
|
-
entryType: 'mark',
|
|
46
|
-
name: reading.name,
|
|
47
|
-
startTime: reading.startTime,
|
|
48
|
-
duration: reading.duration
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
});
|
|
53
|
-
(0, _defineProperty2.default)(this, "convertToEntryList", function (batch) {
|
|
54
|
-
return {
|
|
55
|
-
getEntries: function getEntries() {
|
|
56
|
-
return batch;
|
|
57
|
-
},
|
|
58
|
-
// We ignore type because we only store type of mark in batch
|
|
59
|
-
getEntriesByName: function getEntriesByName(name, type) {
|
|
60
|
-
return batch.filter(function (entry) {
|
|
61
|
-
return entry.name === name;
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
getEntriesByType: function getEntriesByType(type) {
|
|
65
|
-
return batch;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
(0, _defineProperty2.default)(this, "observed", function (reading) {
|
|
70
|
-
// Given that this is only used for tracking transactions and
|
|
71
|
-
// transactions are synchronous, we can assume that anything measured
|
|
72
|
-
// between EVENT_NAME_DISPATCHTRANSACTION is encapsulated.
|
|
73
|
-
var name = reading.name;
|
|
74
|
-
|
|
75
|
-
// Transaction tracking event are prefixed with Owl emoji
|
|
76
|
-
if (name.startsWith('🦉')) {
|
|
77
|
-
var _name$split$;
|
|
78
|
-
// check if its logging InstrumentedPlugin.state.apply()
|
|
79
|
-
var pluginName = ((_name$split$ = name.split(':')[0]) === null || _name$split$ === void 0 ? void 0 : _name$split$.split('🦉')[1]) || '';
|
|
80
|
-
var isPluginApply = _this.pluginNameCache.has(pluginName);
|
|
81
|
-
var isTransactionMeasurement = EVENT_NAMES.includes(name);
|
|
82
|
-
if (!isTransactionMeasurement && process.env.NODE_ENV === 'development') {
|
|
83
|
-
// eslint-disable-next-line no-console
|
|
84
|
-
console.warn("SimpleMeasurementLogger: unknown transaction event name '".concat(name, "'"));
|
|
85
|
-
}
|
|
86
|
-
if (isPluginApply || isTransactionMeasurement) {
|
|
87
|
-
_this.currentBatch.push(_this.createPerformanceEntry(reading));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Trigger a report
|
|
92
|
-
if (name === _trackTransactions.EVENT_NAME_DISPATCH_TRANSACTION) {
|
|
93
|
-
// convert the batch into a bunch of entries
|
|
94
|
-
if (_this.observationCallback) {
|
|
95
|
-
var _entries = _this.convertToEntryList((0, _toConsumableArray2.default)(_this.currentBatch));
|
|
96
|
-
_this.observationCallback(_entries);
|
|
97
|
-
}
|
|
98
|
-
_this.currentBatch = [];
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { percentile } from './percentile';
|
|
2
|
-
export const outlier = (input, factor) => {
|
|
3
|
-
const q1 = percentile(input, 0.25);
|
|
4
|
-
const q3 = percentile(input, 0.75);
|
|
5
|
-
if (typeof q1 === 'undefined' || typeof q3 === 'undefined') {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const iqr = q3 - q1;
|
|
9
|
-
return q3 + iqr * factor;
|
|
10
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const percentile = (input, fraction) => {
|
|
2
|
-
const sorted = input.sort((a, b) => a - b);
|
|
3
|
-
const position = sorted.length * fraction;
|
|
4
|
-
const base = Math.floor(position);
|
|
5
|
-
const rest = position - base;
|
|
6
|
-
if (rest > 0) {
|
|
7
|
-
return sorted[base];
|
|
8
|
-
}
|
|
9
|
-
const item = sorted[base - 1];
|
|
10
|
-
const next = sorted[base];
|
|
11
|
-
if (typeof item !== 'undefined' && typeof next !== 'undefined') {
|
|
12
|
-
return (item + next) / 2;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { PluginPerformanceReport } from './plugin-performance-report';
|
|
3
|
-
import { SimpleMeasurementLogger } from './simple-measure-to-entries';
|
|
4
|
-
import { DEFAULT_USE_PERFORMANCE_MARK, EVENT_NAME_DISPATCH_TRANSACTION } from './track-transactions';
|
|
5
|
-
export class PluginPerformanceObserver {
|
|
6
|
-
constructor(callback) {
|
|
7
|
-
_defineProperty(this, "getNodeCounts", () => [{
|
|
8
|
-
nodeCount: {},
|
|
9
|
-
extensionNodeCount: {}
|
|
10
|
-
}, 0]);
|
|
11
|
-
_defineProperty(this, "getPlugins", () => []);
|
|
12
|
-
_defineProperty(this, "getOptions", () => ({}));
|
|
13
|
-
_defineProperty(this, "reportCount", 0);
|
|
14
|
-
_defineProperty(this, "simpleObserver", new SimpleMeasurementLogger());
|
|
15
|
-
_defineProperty(this, "onObserveration", entries => {
|
|
16
|
-
const reports = entries.getEntriesByName(EVENT_NAME_DISPATCH_TRANSACTION).map(entry => PluginPerformanceReport.fromEntry(entry).withCount(++this.reportCount).withEntryList(entries).withNodes(...this.getNodeCounts()).withPlugins(this.getPlugins()).withOptions(this.getOptions()).toJSON());
|
|
17
|
-
reports.filter(report => report.trigger !== 'none').forEach(report => this.callback(report));
|
|
18
|
-
});
|
|
19
|
-
this.callback = callback;
|
|
20
|
-
this.observer = window.PerformanceObserver ? new PerformanceObserver(this.onObserveration) : {
|
|
21
|
-
observe() {},
|
|
22
|
-
disconnect() {},
|
|
23
|
-
takeRecords() {
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
get isSimpleTracking() {
|
|
29
|
-
const {
|
|
30
|
-
usePerformanceMarks = DEFAULT_USE_PERFORMANCE_MARK
|
|
31
|
-
} = this.getOptions();
|
|
32
|
-
return !usePerformanceMarks;
|
|
33
|
-
}
|
|
34
|
-
withNodeCounts(getNodeCounts) {
|
|
35
|
-
this.getNodeCounts = () => {
|
|
36
|
-
const start = performance.now();
|
|
37
|
-
const result = getNodeCounts();
|
|
38
|
-
return [result, performance.now() - start];
|
|
39
|
-
};
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
withPlugins(getPlugins) {
|
|
43
|
-
this.getPlugins = getPlugins;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
withOptions(getOptions) {
|
|
47
|
-
this.getOptions = getOptions;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
withTransactionTracker(getTransactionTracker) {
|
|
51
|
-
this.getTransactionTracker = getTransactionTracker;
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
observe() {
|
|
55
|
-
if (this.isSimpleTracking) {
|
|
56
|
-
this.simpleObserver.setPluginNames(this.getPlugins());
|
|
57
|
-
this.simpleObserver.setOnObservation(entries => {
|
|
58
|
-
this.onObserveration(entries, this.observer);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// can trigger a callback when stopMeasure() measures something.
|
|
62
|
-
// use that to trigger this.onObservation()
|
|
63
|
-
this.getTransactionTracker && this.getTransactionTracker().addMeasureListener(this.simpleObserver.observed);
|
|
64
|
-
} else {
|
|
65
|
-
try {
|
|
66
|
-
this.observer.observe({
|
|
67
|
-
buffered: false,
|
|
68
|
-
type: 'measure'
|
|
69
|
-
});
|
|
70
|
-
} catch (err) {
|
|
71
|
-
// Older API implementations do not support the simpler type init
|
|
72
|
-
this.observer.observe({
|
|
73
|
-
entryTypes: ['measure']
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
disconnect() {
|
|
79
|
-
if (this.isSimpleTracking) {
|
|
80
|
-
this.getTransactionTracker && this.getTransactionTracker().removeMeasureListener(this.simpleObserver.observed);
|
|
81
|
-
} else {
|
|
82
|
-
this.observer.disconnect();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
takeRecords() {
|
|
86
|
-
return this.observer.takeRecords();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { outlier } from './outlier';
|
|
3
|
-
import { EVENT_NAME_ON_CHANGE, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPDATE_STATE, EVENT_NAME_VIEW_STATE_UPDATED } from './track-transactions';
|
|
4
|
-
export class PluginPerformanceReport {
|
|
5
|
-
constructor(entry) {
|
|
6
|
-
_defineProperty(this, "count", 0);
|
|
7
|
-
_defineProperty(this, "pluginNames", []);
|
|
8
|
-
_defineProperty(this, "nodes", {});
|
|
9
|
-
_defineProperty(this, "extensionNodes", {});
|
|
10
|
-
_defineProperty(this, "nodesDuration", 0);
|
|
11
|
-
_defineProperty(this, "plugins", {});
|
|
12
|
-
_defineProperty(this, "slowPlugins", {});
|
|
13
|
-
_defineProperty(this, "options", {
|
|
14
|
-
samplingRate: 100,
|
|
15
|
-
slowThreshold: 300,
|
|
16
|
-
outlierThreshold: 30,
|
|
17
|
-
outlierFactor: 3
|
|
18
|
-
});
|
|
19
|
-
_defineProperty(this, "isChild", child => child.startTime >= this.entry.startTime && child.startTime + child.duration <= this.entry.startTime + this.entry.duration);
|
|
20
|
-
this.entry = entry;
|
|
21
|
-
}
|
|
22
|
-
static fromEntry(entry) {
|
|
23
|
-
return new PluginPerformanceReport(entry);
|
|
24
|
-
}
|
|
25
|
-
getEntryByName(entryList, name) {
|
|
26
|
-
return entryList.getEntriesByName(name).find(this.isChild);
|
|
27
|
-
}
|
|
28
|
-
getMethodSum(methods) {
|
|
29
|
-
return Object.values(methods).reduce((a, b) => a + b, 0);
|
|
30
|
-
}
|
|
31
|
-
greaterEquals(a, b) {
|
|
32
|
-
return typeof b === 'number' ? a >= b : false;
|
|
33
|
-
}
|
|
34
|
-
hasOutlierMethods(methods, outliers) {
|
|
35
|
-
return this.greaterEquals(methods.stateApply, outliers.stateApplyOutlier) || this.greaterEquals(methods.viewUpdate, outliers.viewUpdateOutlier);
|
|
36
|
-
}
|
|
37
|
-
get trigger() {
|
|
38
|
-
if (this.entry.duration > this.options.slowThreshold) {
|
|
39
|
-
return 'slow';
|
|
40
|
-
} else if (this.hasSlowPlugins && this.entry.duration > this.options.outlierThreshold) {
|
|
41
|
-
return 'distribution';
|
|
42
|
-
} else if (this.count > 0 && this.count % this.options.samplingRate === 0) {
|
|
43
|
-
return 'sample';
|
|
44
|
-
} else {
|
|
45
|
-
return 'none';
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
get hasSlowPlugins() {
|
|
49
|
-
return Object.keys(this.slowPlugins).length > 0;
|
|
50
|
-
}
|
|
51
|
-
withEntryList(entryList) {
|
|
52
|
-
this.entryList = entryList;
|
|
53
|
-
this.stateApplied = this.getEntryByName(entryList, EVENT_NAME_STATE_APPLY);
|
|
54
|
-
this.viewUpdated = this.getEntryByName(entryList, EVENT_NAME_UPDATE_STATE);
|
|
55
|
-
this.onChangeCalled = this.getEntryByName(entryList, EVENT_NAME_ON_CHANGE);
|
|
56
|
-
this.onEditorViewStateUpdatedCalled = this.getEntryByName(entryList, EVENT_NAME_VIEW_STATE_UPDATED);
|
|
57
|
-
this.withPlugins(this.pluginNames);
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
withPlugins(pluginNames) {
|
|
61
|
-
const emptyEntry = {
|
|
62
|
-
duration: 0
|
|
63
|
-
};
|
|
64
|
-
this.pluginNames = pluginNames;
|
|
65
|
-
this.plugins = pluginNames.reduce((acc, name) => {
|
|
66
|
-
const pluginApplied = this.entryList ? this.getEntryByName(this.entryList, `🦉${name}::apply`) || emptyEntry : emptyEntry;
|
|
67
|
-
const pluginViewUpdated = this.entryList ? this.getEntryByName(this.entryList, `🦉${name}::view::update`) || emptyEntry : emptyEntry;
|
|
68
|
-
const pluginOnEditorViewStateUpdated = this.entryList ? this.getEntryByName(this.entryList, `🦉${name}::onEditorViewStateUpdated`) || emptyEntry : emptyEntry;
|
|
69
|
-
acc[name] = {
|
|
70
|
-
stateApply: pluginApplied.duration,
|
|
71
|
-
viewUpdate: pluginViewUpdated.duration,
|
|
72
|
-
onEditorViewStateUpdated: pluginOnEditorViewStateUpdated.duration
|
|
73
|
-
};
|
|
74
|
-
return acc;
|
|
75
|
-
}, {});
|
|
76
|
-
if (this.stateApplied && pluginNames.length > 0) {
|
|
77
|
-
const pluginEntries = Object.entries(this.plugins);
|
|
78
|
-
const stateApplyOutlier = outlier(pluginEntries.map(([, {
|
|
79
|
-
stateApply
|
|
80
|
-
}]) => stateApply), this.options.outlierFactor);
|
|
81
|
-
const viewUpdateOutlier = outlier(pluginEntries.map(([, {
|
|
82
|
-
viewUpdate
|
|
83
|
-
}]) => viewUpdate), this.options.outlierFactor);
|
|
84
|
-
const budget = this.options.outlierThreshold / pluginEntries.length;
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Consider plugin methods slow that are
|
|
88
|
-
* statistically significantly slower than peers
|
|
89
|
-
* AND where the sum of methods for a plugin is slower than 16.7ms / plugins.length
|
|
90
|
-
*/
|
|
91
|
-
const pluginIsOutlier = ([, methods]) => this.getMethodSum(methods) > budget && this.hasOutlierMethods(methods, {
|
|
92
|
-
stateApplyOutlier,
|
|
93
|
-
viewUpdateOutlier
|
|
94
|
-
});
|
|
95
|
-
this.slowPlugins = pluginEntries.filter(pluginIsOutlier).reduce((acc, [n, d]) => ({
|
|
96
|
-
...acc,
|
|
97
|
-
[n]: d
|
|
98
|
-
}), {});
|
|
99
|
-
}
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
withNodes(nodesCount, nodesDuration = 0) {
|
|
103
|
-
this.nodes = nodesCount.nodeCount;
|
|
104
|
-
this.extensionNodes = nodesCount.extensionNodeCount;
|
|
105
|
-
this.nodesDuration = nodesDuration;
|
|
106
|
-
return this;
|
|
107
|
-
}
|
|
108
|
-
withCount(count) {
|
|
109
|
-
this.count = count;
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
withOptions(options) {
|
|
113
|
-
Object.assign(this.options, options);
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
toJSON() {
|
|
117
|
-
return {
|
|
118
|
-
trigger: this.trigger,
|
|
119
|
-
duration: this.entry.duration,
|
|
120
|
-
nodes: this.nodes,
|
|
121
|
-
extensionNodes: this.extensionNodes,
|
|
122
|
-
plugins: this.plugins,
|
|
123
|
-
slowPlugins: this.slowPlugins,
|
|
124
|
-
stepDurations: {
|
|
125
|
-
stateApply: this.stateApplied ? this.stateApplied.duration : 0,
|
|
126
|
-
viewUpdate: this.viewUpdated ? this.viewUpdated.duration : 0,
|
|
127
|
-
onChange: this.onChangeCalled ? this.onChangeCalled.duration : 0,
|
|
128
|
-
onEditorViewStateUpdated: this.onEditorViewStateUpdatedCalled ? this.onEditorViewStateUpdatedCalled.duration : 0,
|
|
129
|
-
countNodes: this.nodesDuration
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import { EVENT_NAME_DISPATCH_TRANSACTION, EVENT_NAME_ON_CHANGE, EVENT_NAME_STATE_APPLY, EVENT_NAME_UPDATE_STATE, EVENT_NAME_VIEW_STATE_UPDATED } from './track-transactions';
|
|
3
|
-
const EVENT_NAMES = [EVENT_NAME_STATE_APPLY, EVENT_NAME_UPDATE_STATE, EVENT_NAME_VIEW_STATE_UPDATED, EVENT_NAME_ON_CHANGE, EVENT_NAME_DISPATCH_TRANSACTION];
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A class that logs and collates measurement entries until
|
|
7
|
-
* EVENT_NAME_DISPATCHTRANSACTION is detected.
|
|
8
|
-
*
|
|
9
|
-
* At that point, it will group together all the entries
|
|
10
|
-
* logged and fire a callback with all entries packaged
|
|
11
|
-
* into a PerformanceObserverEntryList.
|
|
12
|
-
*
|
|
13
|
-
* We are able to make use of this method as the measurements
|
|
14
|
-
* which occur during dispatchTransactions are synchronous.
|
|
15
|
-
*/
|
|
16
|
-
export class SimpleMeasurementLogger {
|
|
17
|
-
constructor() {
|
|
18
|
-
_defineProperty(this, "currentBatch", []);
|
|
19
|
-
_defineProperty(this, "pluginNameCache", new Set());
|
|
20
|
-
_defineProperty(this, "setPluginNames", names => {
|
|
21
|
-
this.pluginNameCache = new Set(names);
|
|
22
|
-
});
|
|
23
|
-
_defineProperty(this, "setOnObservation", callback => {
|
|
24
|
-
this.observationCallback = callback;
|
|
25
|
-
});
|
|
26
|
-
_defineProperty(this, "createPerformanceEntry", reading => {
|
|
27
|
-
return {
|
|
28
|
-
entryType: 'mark',
|
|
29
|
-
name: reading.name,
|
|
30
|
-
startTime: reading.startTime,
|
|
31
|
-
duration: reading.duration,
|
|
32
|
-
toJSON: () => JSON.stringify({
|
|
33
|
-
entryType: 'mark',
|
|
34
|
-
name: reading.name,
|
|
35
|
-
startTime: reading.startTime,
|
|
36
|
-
duration: reading.duration
|
|
37
|
-
})
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
_defineProperty(this, "convertToEntryList", batch => {
|
|
41
|
-
return {
|
|
42
|
-
getEntries: () => batch,
|
|
43
|
-
// We ignore type because we only store type of mark in batch
|
|
44
|
-
getEntriesByName: (name, type) => batch.filter(entry => entry.name === name),
|
|
45
|
-
getEntriesByType: type => batch
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
_defineProperty(this, "observed", reading => {
|
|
49
|
-
// Given that this is only used for tracking transactions and
|
|
50
|
-
// transactions are synchronous, we can assume that anything measured
|
|
51
|
-
// between EVENT_NAME_DISPATCHTRANSACTION is encapsulated.
|
|
52
|
-
const {
|
|
53
|
-
name
|
|
54
|
-
} = reading;
|
|
55
|
-
|
|
56
|
-
// Transaction tracking event are prefixed with Owl emoji
|
|
57
|
-
if (name.startsWith('🦉')) {
|
|
58
|
-
var _name$split$;
|
|
59
|
-
// check if its logging InstrumentedPlugin.state.apply()
|
|
60
|
-
const pluginName = ((_name$split$ = name.split(':')[0]) === null || _name$split$ === void 0 ? void 0 : _name$split$.split('🦉')[1]) || '';
|
|
61
|
-
const isPluginApply = this.pluginNameCache.has(pluginName);
|
|
62
|
-
const isTransactionMeasurement = EVENT_NAMES.includes(name);
|
|
63
|
-
if (!isTransactionMeasurement && process.env.NODE_ENV === 'development') {
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
|
-
console.warn(`SimpleMeasurementLogger: unknown transaction event name '${name}'`);
|
|
66
|
-
}
|
|
67
|
-
if (isPluginApply || isTransactionMeasurement) {
|
|
68
|
-
this.currentBatch.push(this.createPerformanceEntry(reading));
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Trigger a report
|
|
73
|
-
if (name === EVENT_NAME_DISPATCH_TRANSACTION) {
|
|
74
|
-
// convert the batch into a bunch of entries
|
|
75
|
-
if (this.observationCallback) {
|
|
76
|
-
const entries = this.convertToEntryList([...this.currentBatch]);
|
|
77
|
-
this.observationCallback(entries);
|
|
78
|
-
}
|
|
79
|
-
this.currentBatch = [];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { percentile } from './percentile';
|
|
2
|
-
export var outlier = function outlier(input, factor) {
|
|
3
|
-
var q1 = percentile(input, 0.25);
|
|
4
|
-
var q3 = percentile(input, 0.75);
|
|
5
|
-
if (typeof q1 === 'undefined' || typeof q3 === 'undefined') {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
var iqr = q3 - q1;
|
|
9
|
-
return q3 + iqr * factor;
|
|
10
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export var percentile = function percentile(input, fraction) {
|
|
2
|
-
var sorted = input.sort(function (a, b) {
|
|
3
|
-
return a - b;
|
|
4
|
-
});
|
|
5
|
-
var position = sorted.length * fraction;
|
|
6
|
-
var base = Math.floor(position);
|
|
7
|
-
var rest = position - base;
|
|
8
|
-
if (rest > 0) {
|
|
9
|
-
return sorted[base];
|
|
10
|
-
}
|
|
11
|
-
var item = sorted[base - 1];
|
|
12
|
-
var next = sorted[base];
|
|
13
|
-
if (typeof item !== 'undefined' && typeof next !== 'undefined') {
|
|
14
|
-
return (item + next) / 2;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
-
import { PluginPerformanceReport } from './plugin-performance-report';
|
|
6
|
-
import { SimpleMeasurementLogger } from './simple-measure-to-entries';
|
|
7
|
-
import { DEFAULT_USE_PERFORMANCE_MARK, EVENT_NAME_DISPATCH_TRANSACTION } from './track-transactions';
|
|
8
|
-
export var PluginPerformanceObserver = /*#__PURE__*/function () {
|
|
9
|
-
function PluginPerformanceObserver(callback) {
|
|
10
|
-
var _this = this;
|
|
11
|
-
_classCallCheck(this, PluginPerformanceObserver);
|
|
12
|
-
_defineProperty(this, "getNodeCounts", function () {
|
|
13
|
-
return [{
|
|
14
|
-
nodeCount: {},
|
|
15
|
-
extensionNodeCount: {}
|
|
16
|
-
}, 0];
|
|
17
|
-
});
|
|
18
|
-
_defineProperty(this, "getPlugins", function () {
|
|
19
|
-
return [];
|
|
20
|
-
});
|
|
21
|
-
_defineProperty(this, "getOptions", function () {
|
|
22
|
-
return {};
|
|
23
|
-
});
|
|
24
|
-
_defineProperty(this, "reportCount", 0);
|
|
25
|
-
_defineProperty(this, "simpleObserver", new SimpleMeasurementLogger());
|
|
26
|
-
_defineProperty(this, "onObserveration", function (entries) {
|
|
27
|
-
var reports = entries.getEntriesByName(EVENT_NAME_DISPATCH_TRANSACTION).map(function (entry) {
|
|
28
|
-
var _PluginPerformanceRep;
|
|
29
|
-
return (_PluginPerformanceRep = PluginPerformanceReport.fromEntry(entry).withCount(++_this.reportCount).withEntryList(entries)).withNodes.apply(_PluginPerformanceRep, _toConsumableArray(_this.getNodeCounts())).withPlugins(_this.getPlugins()).withOptions(_this.getOptions()).toJSON();
|
|
30
|
-
});
|
|
31
|
-
reports.filter(function (report) {
|
|
32
|
-
return report.trigger !== 'none';
|
|
33
|
-
}).forEach(function (report) {
|
|
34
|
-
return _this.callback(report);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
this.callback = callback;
|
|
38
|
-
this.observer = window.PerformanceObserver ? new PerformanceObserver(this.onObserveration) : {
|
|
39
|
-
observe: function observe() {},
|
|
40
|
-
disconnect: function disconnect() {},
|
|
41
|
-
takeRecords: function takeRecords() {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return _createClass(PluginPerformanceObserver, [{
|
|
47
|
-
key: "isSimpleTracking",
|
|
48
|
-
get: function get() {
|
|
49
|
-
var _this$getOptions = this.getOptions(),
|
|
50
|
-
_this$getOptions$useP = _this$getOptions.usePerformanceMarks,
|
|
51
|
-
usePerformanceMarks = _this$getOptions$useP === void 0 ? DEFAULT_USE_PERFORMANCE_MARK : _this$getOptions$useP;
|
|
52
|
-
return !usePerformanceMarks;
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "withNodeCounts",
|
|
56
|
-
value: function withNodeCounts(getNodeCounts) {
|
|
57
|
-
this.getNodeCounts = function () {
|
|
58
|
-
var start = performance.now();
|
|
59
|
-
var result = getNodeCounts();
|
|
60
|
-
return [result, performance.now() - start];
|
|
61
|
-
};
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: "withPlugins",
|
|
66
|
-
value: function withPlugins(getPlugins) {
|
|
67
|
-
this.getPlugins = getPlugins;
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
}, {
|
|
71
|
-
key: "withOptions",
|
|
72
|
-
value: function withOptions(getOptions) {
|
|
73
|
-
this.getOptions = getOptions;
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
}, {
|
|
77
|
-
key: "withTransactionTracker",
|
|
78
|
-
value: function withTransactionTracker(getTransactionTracker) {
|
|
79
|
-
this.getTransactionTracker = getTransactionTracker;
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "observe",
|
|
84
|
-
value: function observe() {
|
|
85
|
-
var _this2 = this;
|
|
86
|
-
if (this.isSimpleTracking) {
|
|
87
|
-
this.simpleObserver.setPluginNames(this.getPlugins());
|
|
88
|
-
this.simpleObserver.setOnObservation(function (entries) {
|
|
89
|
-
_this2.onObserveration(entries, _this2.observer);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
// can trigger a callback when stopMeasure() measures something.
|
|
93
|
-
// use that to trigger this.onObservation()
|
|
94
|
-
this.getTransactionTracker && this.getTransactionTracker().addMeasureListener(this.simpleObserver.observed);
|
|
95
|
-
} else {
|
|
96
|
-
try {
|
|
97
|
-
this.observer.observe({
|
|
98
|
-
buffered: false,
|
|
99
|
-
type: 'measure'
|
|
100
|
-
});
|
|
101
|
-
} catch (err) {
|
|
102
|
-
// Older API implementations do not support the simpler type init
|
|
103
|
-
this.observer.observe({
|
|
104
|
-
entryTypes: ['measure']
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}, {
|
|
110
|
-
key: "disconnect",
|
|
111
|
-
value: function disconnect() {
|
|
112
|
-
if (this.isSimpleTracking) {
|
|
113
|
-
this.getTransactionTracker && this.getTransactionTracker().removeMeasureListener(this.simpleObserver.observed);
|
|
114
|
-
} else {
|
|
115
|
-
this.observer.disconnect();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "takeRecords",
|
|
120
|
-
value: function takeRecords() {
|
|
121
|
-
return this.observer.takeRecords();
|
|
122
|
-
}
|
|
123
|
-
}]);
|
|
124
|
-
}();
|