@adaptabletools/adaptable 24.0.1 → 24.0.3
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/devtools.d.ts +506 -5
- package/devtools.js +11 -1
- package/index.css +15 -5
- package/package.json +1 -1
- package/src/AdaptableInterfaces/IAdaptable.d.ts +6 -1
- package/src/AdaptableOptions/DataImportOptions.d.ts +1 -1
- package/src/AdaptableOptions/ExportOptions.d.ts +2 -2
- package/src/AdaptableState/Common/AdaptableFormat.d.ts +2 -10
- package/src/AdaptableState/Common/RowSummary.d.ts +2 -0
- package/src/AdaptableState/LayoutState.d.ts +1 -1
- package/src/Api/Implementation/AlertApiImpl.js +2 -0
- package/src/Api/Internal/CalculatedColumnInternalApi.js +25 -3
- package/src/Api/Internal/ExportInternalApi.d.ts +2 -0
- package/src/Api/Internal/ExportInternalApi.js +39 -3
- package/src/Api/Internal/FormatColumnInternalApi.d.ts +3 -2
- package/src/Api/Internal/FormatColumnInternalApi.js +15 -7
- package/src/Api/Internal/LayoutInternalApi.d.ts +11 -1
- package/src/Api/Internal/LayoutInternalApi.js +34 -3
- package/src/Api/Internal/NoteInternalApi.d.ts +12 -0
- package/src/Api/Internal/NoteInternalApi.js +11 -0
- package/src/EnvVars.d.ts +1 -0
- package/src/EnvVars.js +1 -0
- package/src/Redux/Store/AdaptableStore.js +4 -7
- package/src/Strategy/FlashingCellModule.js +2 -0
- package/src/Utilities/Services/CalculatedColumnExpressionService.d.ts +1 -0
- package/src/Utilities/Services/CalculatedColumnExpressionService.js +15 -0
- package/src/Utilities/Services/Interface/ICalculatedColumnExpressionService.d.ts +7 -0
- package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +17 -1
- package/src/Utilities/Services/QueryLanguageService.d.ts +11 -1
- package/src/Utilities/Services/QueryLanguageService.js +47 -2
- package/src/Utilities/Services/RowSummaryService.d.ts +2 -0
- package/src/Utilities/Services/RowSummaryService.js +6 -1
- package/src/Utilities/license/instanceLicense.d.ts +12 -0
- package/src/Utilities/license/instanceLicense.js +10 -0
- package/src/Utilities/license/licenseStatus.d.ts +26 -0
- package/src/Utilities/license/licenseStatus.js +72 -0
- package/src/View/Components/CellPopup/index.js +15 -10
- package/src/View/GridInfo/GridInfoPopup.js +6 -1
- package/src/View/Layout/TransposedPopup.js +1 -0
- package/src/View/Layout/Wizard/sections/AggregationsSection.d.ts +3 -5
- package/src/View/Layout/Wizard/sections/AggregationsSection.js +10 -24
- package/src/View/Layout/Wizard/sections/RowSummarySection.js +5 -1
- package/src/View/ObjectItemViews/Layout/aggregationSummaryHelpers.d.ts +5 -1
- package/src/View/ObjectItemViews/Layout/aggregationSummaryHelpers.js +6 -3
- package/src/agGrid/AdaptableAgGrid.d.ts +7 -3
- package/src/agGrid/AdaptableAgGrid.js +144 -78
- package/src/agGrid/AdaptableFilterHandler.d.ts +2 -0
- package/src/agGrid/AdaptableFilterHandler.js +34 -0
- package/src/agGrid/AgGridAdapter.d.ts +9 -0
- package/src/agGrid/AgGridAdapter.js +23 -12
- package/src/agGrid/AgGridColumnAdapter.d.ts +2 -0
- package/src/agGrid/AgGridColumnAdapter.js +124 -78
- package/src/agGrid/AgGridExportAdapter.d.ts +5 -0
- package/src/agGrid/AgGridExportAdapter.js +31 -0
- package/src/agGrid/AgGridMenuAdapter.js +1 -1
- package/src/agGrid/applyGlobalGridOptions.d.ts +9 -0
- package/src/agGrid/applyGlobalGridOptions.js +36 -0
- package/src/agGrid/cellRenderers/BadgeRenderer.js +22 -0
- package/src/agGrid/columnMinMaxCache.d.ts +33 -0
- package/src/agGrid/columnMinMaxCache.js +50 -0
- package/src/devTools/PerfStore.d.ts +218 -0
- package/src/devTools/PerfStore.js +717 -0
- package/src/devTools/index.d.ts +33 -0
- package/src/devTools/index.js +132 -56
- package/src/devTools/logBuffer.d.ts +17 -0
- package/src/devTools/logBuffer.js +33 -0
- package/src/devTools/memoryInfo.d.ts +15 -0
- package/src/devTools/memoryInfo.js +229 -0
- package/src/devTools/memoryRoots.d.ts +41 -0
- package/src/devTools/memoryRoots.js +136 -0
- package/src/devTools/perfContext.d.ts +5 -0
- package/src/devTools/perfContext.js +155 -0
- package/src/devTools/perfInstrumentation.d.ts +13 -0
- package/src/devTools/perfInstrumentation.js +78 -0
- package/src/env.js +2 -2
- package/src/layout-manager/src/LayoutManagerModel.d.ts +3 -1
- package/src/layout-manager/src/expandAllRowGroups.d.ts +6 -0
- package/src/layout-manager/src/expandAllRowGroups.js +13 -0
- package/src/layout-manager/src/index.js +18 -10
- package/src/setupDevTools.js +560 -106
- package/tsconfig.esm.tsbuildinfo +1 -1
- package/vendor/aql/api/QueryLanguageApi.d.ts +2 -1
- package/vendor/aql/api/QueryLanguageApi.d.ts.map +1 -1
- package/vendor/aql/api/QueryLanguageApi.js +28 -108
- package/vendor/aql/api/QueryLanguageApi.js.map +1 -1
- package/vendor/aql/contract/index.js +0 -34
- package/vendor/aql/contract/index.js.map +1 -1
- package/vendor/aql/corpus/corpusExpressions.js +0 -13
- package/vendor/aql/corpus/corpusExpressions.js.map +1 -1
- package/vendor/aql/corpus/corpusFixture.js +0 -7
- package/vendor/aql/corpus/corpusFixture.js.map +1 -1
- package/vendor/aql/draft/index.js +0 -4
- package/vendor/aql/draft/index.js.map +1 -1
- package/vendor/aql/evaluate.js +0 -22
- package/vendor/aql/evaluate.js.map +1 -1
- package/vendor/aql/evaluator/ExpressionEvaluationError.js +0 -4
- package/vendor/aql/evaluator/ExpressionEvaluationError.js.map +1 -1
- package/vendor/aql/evaluator/ExpressionNaError.js +0 -4
- package/vendor/aql/evaluator/ExpressionNaError.js.map +1 -1
- package/vendor/aql/evaluator/evaluateNode.js +0 -23
- package/vendor/aql/evaluator/evaluateNode.js.map +1 -1
- package/vendor/aql/functions/dateUtils.js +0 -63
- package/vendor/aql/functions/dateUtils.js.map +1 -1
- package/vendor/aql/functions/numberUtils.js +0 -12
- package/vendor/aql/functions/numberUtils.js.map +1 -1
- package/vendor/aql/functions/operatorFunctions.js +0 -13
- package/vendor/aql/functions/operatorFunctions.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/AND.js +0 -5
- package/vendor/aql/functions/scalar/functions/AND.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/ANY_CHANGE.js +0 -4
- package/vendor/aql/functions/scalar/functions/ANY_CHANGE.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/ANY_CONTAINS.js +0 -4
- package/vendor/aql/functions/scalar/functions/ANY_CONTAINS.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/AVG.js +0 -1
- package/vendor/aql/functions/scalar/functions/AVG.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/CASE.js +2 -2
- package/vendor/aql/functions/scalar/functions/CASE.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/COL.js +0 -2
- package/vendor/aql/functions/scalar/functions/COL.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/CONTAINS.js +0 -3
- package/vendor/aql/functions/scalar/functions/CONTAINS.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/DATE.js +0 -2
- package/vendor/aql/functions/scalar/functions/DATE.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/ENDS_WITH.js +0 -1
- package/vendor/aql/functions/scalar/functions/ENDS_WITH.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/EQ.js +0 -5
- package/vendor/aql/functions/scalar/functions/EQ.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/GT.js +0 -3
- package/vendor/aql/functions/scalar/functions/GT.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/GTE.js +0 -3
- package/vendor/aql/functions/scalar/functions/GTE.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IF.js +0 -5
- package/vendor/aql/functions/scalar/functions/IF.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IFERROR.js +0 -4
- package/vendor/aql/functions/scalar/functions/IFERROR.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IFNA.js +0 -5
- package/vendor/aql/functions/scalar/functions/IFNA.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IN.d.ts.map +1 -1
- package/vendor/aql/functions/scalar/functions/IN.js +54 -11
- package/vendor/aql/functions/scalar/functions/IN.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IS_BLANK.js +0 -1
- package/vendor/aql/functions/scalar/functions/IS_BLANK.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IS_DIFFERENT_DAY.js +0 -1
- package/vendor/aql/functions/scalar/functions/IS_DIFFERENT_DAY.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/IS_NOT_BLANK.js +0 -1
- package/vendor/aql/functions/scalar/functions/IS_NOT_BLANK.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/LT.js +0 -3
- package/vendor/aql/functions/scalar/functions/LT.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/LTE.js +0 -3
- package/vendor/aql/functions/scalar/functions/LTE.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/NA.js +0 -3
- package/vendor/aql/functions/scalar/functions/NA.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/NOT_CONTAINS.js +0 -1
- package/vendor/aql/functions/scalar/functions/NOT_CONTAINS.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/NOT_IN.js +0 -3
- package/vendor/aql/functions/scalar/functions/NOT_IN.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/OR.js +0 -4
- package/vendor/aql/functions/scalar/functions/OR.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/PRODUCT.js +0 -6
- package/vendor/aql/functions/scalar/functions/PRODUCT.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/QUERY.js +0 -1
- package/vendor/aql/functions/scalar/functions/QUERY.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/REGEX.js +0 -1
- package/vendor/aql/functions/scalar/functions/REGEX.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/SCOPE.js +0 -4
- package/vendor/aql/functions/scalar/functions/SCOPE.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/STARTS_WITH.js +0 -1
- package/vendor/aql/functions/scalar/functions/STARTS_WITH.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/SUB.js +0 -1
- package/vendor/aql/functions/scalar/functions/SUB.js.map +1 -1
- package/vendor/aql/functions/scalar/functions/SUM.js +0 -5
- package/vendor/aql/functions/scalar/functions/SUM.js.map +1 -1
- package/vendor/aql/functions/scalar/helpers.js +0 -3
- package/vendor/aql/functions/scalar/helpers.js.map +1 -1
- package/vendor/aql/functions/shared/FIELD.js +0 -3
- package/vendor/aql/functions/shared/FIELD.js.map +1 -1
- package/vendor/aql/functions/shared/VAR.js +0 -4
- package/vendor/aql/functions/shared/VAR.js.map +1 -1
- package/vendor/aql/functions/shared/index.js +0 -9
- package/vendor/aql/functions/shared/index.js.map +1 -1
- package/vendor/aql/functions/stringUtils.js +0 -25
- package/vendor/aql/functions/stringUtils.js.map +1 -1
- package/vendor/aql/functions/utils.js +0 -20
- package/vendor/aql/functions/utils.js.map +1 -1
- package/vendor/aql/host/access.js +0 -2
- package/vendor/aql/host/access.js.map +1 -1
- package/vendor/aql/host/createHostExpressionContext.js +0 -25
- package/vendor/aql/host/createHostExpressionContext.js.map +1 -1
- package/vendor/aql/host/createObjectDataHost.js +0 -9
- package/vendor/aql/host/createObjectDataHost.js.map +1 -1
- package/vendor/aql/index.js +0 -2
- package/vendor/aql/index.js.map +1 -1
- package/vendor/aql/normalize/canonicalize.js +0 -7
- package/vendor/aql/normalize/canonicalize.js.map +1 -1
- package/vendor/aql/normalize/migrateExpression.js +0 -8
- package/vendor/aql/normalize/migrateExpression.js.map +1 -1
- package/vendor/aql/normalize/names.js +0 -72
- package/vendor/aql/normalize/names.js.map +1 -1
- package/vendor/aql/normalize/normalizeAst.js +0 -102
- package/vendor/aql/normalize/normalizeAst.js.map +1 -1
- package/vendor/aql/normalize/print.js +0 -35
- package/vendor/aql/normalize/print.js.map +1 -1
- package/vendor/aql/operator/primitiveSlots.js +0 -4
- package/vendor/aql/operator/primitiveSlots.js.map +1 -1
- package/vendor/aql/operator/resolve.js +0 -18
- package/vendor/aql/operator/resolve.js.map +1 -1
- package/vendor/aql/parser/parser.js +4 -125
- package/vendor/aql/parser/parser.js.map +1 -1
- package/vendor/aql/plan/catalogue.js +0 -35
- package/vendor/aql/plan/catalogue.js.map +1 -1
- package/vendor/aql/plan/compile.js +0 -68
- package/vendor/aql/plan/compile.js.map +1 -1
- package/vendor/aql/plan/deepMap.js +0 -16
- package/vendor/aql/plan/deepMap.js.map +1 -1
- package/vendor/aql/plan/execute.js +0 -91
- package/vendor/aql/plan/execute.js.map +1 -1
- package/vendor/aql/plan/magnitudeLiteral.js +0 -29
- package/vendor/aql/plan/magnitudeLiteral.js.map +1 -1
- package/vendor/aql/plan/observable.js +0 -31
- package/vendor/aql/plan/observable.js.map +1 -1
- package/vendor/aql/plan/observableFixture.js +0 -3
- package/vendor/aql/plan/observableFixture.js.map +1 -1
- package/vendor/aql/plan/operators.js +0 -35
- package/vendor/aql/plan/operators.js.map +1 -1
- package/vendor/aql/plan/outer.js +0 -16
- package/vendor/aql/plan/outer.js.map +1 -1
- package/vendor/aql/predicate/mapExpressionToQlPredicate.js +1 -46
- package/vendor/aql/predicate/mapExpressionToQlPredicate.js.map +1 -1
- package/vendor/aql/predicate/mapQlPredicateToExpression.js +0 -13
- package/vendor/aql/predicate/mapQlPredicateToExpression.js.map +1 -1
- package/vendor/aql/store/computedValueStore.js +0 -35
- package/vendor/aql/store/computedValueStore.js.map +1 -1
- package/vendor/aql/store/history/clock.js +0 -1
- package/vendor/aql/store/history/clock.js.map +1 -1
- package/vendor/aql/store/history/historyStore.js +0 -14
- package/vendor/aql/store/history/historyStore.js.map +1 -1
- package/vendor/aql/store/history/monotonicDeque.js +0 -9
- package/vendor/aql/store/history/monotonicDeque.js.map +1 -1
- package/vendor/aql/store/history/operators.js +0 -13
- package/vendor/aql/store/history/operators.js.map +1 -1
- package/vendor/aql/store/history/ringBuffer.js +0 -12
- package/vendor/aql/store/history/ringBuffer.js.map +1 -1
- package/vendor/aql/store/history/rowSeries.js +0 -17
- package/vendor/aql/store/history/rowSeries.js.map +1 -1
- package/vendor/aql/store/history/types.js +0 -18
- package/vendor/aql/store/history/types.js.map +1 -1
- package/vendor/aql/tokenizer/tokenizer.js +0 -3
- package/vendor/aql/tokenizer/tokenizer.js.map +1 -1
- package/vendor/aql/types.js +0 -27
- package/vendor/aql/types.js.map +1 -1
- package/vendor/aql/utils/astUtils.js +0 -1
- package/vendor/aql/utils/astUtils.js.map +1 -1
- package/vendor/aql/utils/dependencyCycle.js +0 -5
- package/vendor/aql/utils/dependencyCycle.js.map +1 -1
- package/vendor/aql/validation/classifyExpression.js +0 -4
- package/vendor/aql/validation/classifyExpression.js.map +1 -1
- package/vendor/aql/validation/functionMetadata.js +0 -31
- package/vendor/aql/validation/functionMetadata.js.map +1 -1
- package/vendor/aql/validation/validateAqlExpression.js +2 -81
- package/vendor/aql/validation/validateAqlExpression.js.map +1 -1
- package/vendor/aql/validation/validateExpressionTypes.js +0 -64
- package/vendor/aql/validation/validateExpressionTypes.js.map +1 -1
- package/vendor/components/Button/index.js +0 -6
- package/vendor/components/Button/index.js.map +1 -1
- package/vendor/components/ColorField/index.js +0 -18
- package/vendor/components/ColorField/index.js.map +1 -1
- package/vendor/components/ColorPicker/colorPickerTab.js +0 -6
- package/vendor/components/ColorPicker/colorPickerTab.js.map +1 -1
- package/vendor/components/ColorPicker/index.js +1 -66
- package/vendor/components/ColorPicker/index.js.map +1 -1
- package/vendor/components/ColorPicker/themeColors.js +0 -55
- package/vendor/components/ColorPicker/themeColors.js.map +1 -1
- package/vendor/components/Combobox/VirtualizedList.js +0 -5
- package/vendor/components/Combobox/VirtualizedList.js.map +1 -1
- package/vendor/components/Combobox/comboboxUtils.js +0 -5
- package/vendor/components/Combobox/comboboxUtils.js.map +1 -1
- package/vendor/components/Combobox/index.js +7 -106
- package/vendor/components/Combobox/index.js.map +1 -1
- package/vendor/components/Combobox/useScrollNearEnd.js +0 -6
- package/vendor/components/Combobox/useScrollNearEnd.js.map +1 -1
- package/vendor/components/DropdownButton/index.js +0 -5
- package/vendor/components/DropdownButton/index.js.map +1 -1
- package/vendor/components/NumberInput/index.js +0 -10
- package/vendor/components/NumberInput/index.js.map +1 -1
- package/vendor/components/Radio/index.d.ts.map +1 -1
- package/vendor/components/Radio/index.js +1 -1
- package/vendor/components/Radio/index.js.map +1 -1
- package/vendor/components/Resizable/index.d.ts +14 -9
- package/vendor/components/Resizable/index.d.ts.map +1 -1
- package/vendor/components/Resizable/index.js +26 -26
- package/vendor/components/Resizable/index.js.map +1 -1
- package/vendor/components/Resizable/resizableUtils.d.ts +24 -13
- package/vendor/components/Resizable/resizableUtils.d.ts.map +1 -1
- package/vendor/components/Resizable/resizableUtils.js +13 -27
- package/vendor/components/Resizable/resizableUtils.js.map +1 -1
- package/vendor/components/SearchInput/index.js +0 -5
- package/vendor/components/SearchInput/index.js.map +1 -1
- package/vendor/components/Tree/TreeDropdown/index.js +3 -139
- package/vendor/components/Tree/TreeDropdown/index.js.map +1 -1
- package/vendor/components/Tree/treeUtils.js +0 -4
- package/vendor/components/Tree/treeUtils.js.map +1 -1
- package/vendor/components/index.css +12 -5
- package/vendor/components/index.js +0 -5
- package/vendor/components/index.js.map +1 -1
- package/vendor/components/lib/useProperty.js +0 -18
- package/vendor/components/lib/useProperty.js.map +1 -1
- package/vendor/components/twMerge.js +0 -2
- package/vendor/components/twMerge.js.map +1 -1
- package/vendor/components/twUtils.js +3 -12
- package/vendor/components/twUtils.js.map +1 -1
- package/vendor/components/ui/alert-dialog.js +0 -4
- package/vendor/components/ui/alert-dialog.js.map +1 -1
- package/vendor/components/ui/calendar.js +1 -9
- package/vendor/components/ui/calendar.js.map +1 -1
- package/vendor/components/ui/combobox.js +3 -39
- package/vendor/components/ui/combobox.js.map +1 -1
- package/vendor/components/ui/dialog.js +0 -4
- package/vendor/components/ui/dialog.js.map +1 -1
- package/vendor/components/ui/input-group.js +3 -12
- package/vendor/components/ui/input-group.js.map +1 -1
- package/vendor/components/ui/input.js +1 -1
- package/vendor/components/ui/input.js.map +1 -1
- package/vendor/components/ui/select.js +1 -1
- package/vendor/components/ui/select.js.map +1 -1
- package/vendor/components/ui/tabs.js +0 -3
- package/vendor/components/ui/tabs.js.map +1 -1
- package/vendor/components/ui/textarea.js +1 -1
- package/vendor/components/ui/textarea.js.map +1 -1
- package/vendor/components/ui/tooltip.d.ts.map +1 -1
- package/vendor/components/ui/tooltip.js +3 -1
- package/vendor/components/ui/tooltip.js.map +1 -1
|
@@ -0,0 +1,717 @@
|
|
|
1
|
+
import { DevToolsTracks } from './DevToolsTracks';
|
|
2
|
+
const MAX_MEASURES = 500;
|
|
3
|
+
const MAX_LABEL_SAMPLES = 200;
|
|
4
|
+
const MAX_LABEL_STATS = 500;
|
|
5
|
+
const MAX_LONG_FRAMES = 200;
|
|
6
|
+
const MAX_HOT_PATHS = 2000;
|
|
7
|
+
const MAX_LONG_FRAME_SCRIPTS = 5;
|
|
8
|
+
const HEAP_SAMPLE_INTERVAL_MS = 2000;
|
|
9
|
+
const TICKING_WINDOW_SEC = 5;
|
|
10
|
+
const MAX_RECORDING_HEAP_POINTS = 600;
|
|
11
|
+
const MAX_INVENTORY_SAMPLES = 120;
|
|
12
|
+
const INVENTORY_SAMPLE_INTERVAL_MS = 30_000;
|
|
13
|
+
const INVENTORY_COST_FACTOR = 1000;
|
|
14
|
+
const MAX_RECENT_INVENTORY_READS = 5;
|
|
15
|
+
const INITIALISATION_TRACK = DevToolsTracks.Init.track;
|
|
16
|
+
export class RingBuffer {
|
|
17
|
+
max;
|
|
18
|
+
items = [];
|
|
19
|
+
lastSeq = 0;
|
|
20
|
+
constructor(max) {
|
|
21
|
+
this.max = max;
|
|
22
|
+
}
|
|
23
|
+
push(item) {
|
|
24
|
+
const entry = { ...item, seq: ++this.lastSeq };
|
|
25
|
+
this.items.push(entry);
|
|
26
|
+
if (this.items.length > this.max) {
|
|
27
|
+
this.items.splice(0, this.items.length - this.max);
|
|
28
|
+
}
|
|
29
|
+
return entry;
|
|
30
|
+
}
|
|
31
|
+
since(cursor = 0) {
|
|
32
|
+
if (!this.items.length || cursor >= this.lastSeq) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
let index = this.items.length;
|
|
36
|
+
while (index > 0 && this.items[index - 1].seq > cursor) {
|
|
37
|
+
index--;
|
|
38
|
+
}
|
|
39
|
+
return this.items.slice(index);
|
|
40
|
+
}
|
|
41
|
+
retain(keep) {
|
|
42
|
+
this.items = this.items.filter(keep);
|
|
43
|
+
}
|
|
44
|
+
all() {
|
|
45
|
+
return this.items;
|
|
46
|
+
}
|
|
47
|
+
get seq() {
|
|
48
|
+
return this.lastSeq;
|
|
49
|
+
}
|
|
50
|
+
get size() {
|
|
51
|
+
return this.items.length;
|
|
52
|
+
}
|
|
53
|
+
clear() {
|
|
54
|
+
this.items = [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function percentile(values, p) {
|
|
58
|
+
if (!values.length) {
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
const sorted = [...values].sort((a, b) => a - b);
|
|
62
|
+
const index = Math.min(sorted.length - 1, Math.ceil((p / 100) * sorted.length) - 1);
|
|
63
|
+
return sorted[Math.max(0, index)];
|
|
64
|
+
}
|
|
65
|
+
function round(value) {
|
|
66
|
+
return Math.round(value * 100) / 100;
|
|
67
|
+
}
|
|
68
|
+
function toEpoch(perfTime) {
|
|
69
|
+
const origin = typeof performance !== 'undefined' && typeof performance.timeOrigin === 'number'
|
|
70
|
+
? performance.timeOrigin
|
|
71
|
+
: Date.now() - (typeof performance !== 'undefined' ? performance.now() : 0);
|
|
72
|
+
return origin + perfTime;
|
|
73
|
+
}
|
|
74
|
+
class TickingCounters {
|
|
75
|
+
totals = {
|
|
76
|
+
cellChanges: 0,
|
|
77
|
+
rowTransactions: 0,
|
|
78
|
+
flashes: 0,
|
|
79
|
+
alertsFired: 0,
|
|
80
|
+
refiltersFromDataChange: 0,
|
|
81
|
+
};
|
|
82
|
+
buckets = new Map();
|
|
83
|
+
add(name, amount) {
|
|
84
|
+
this.totals[name] += amount;
|
|
85
|
+
const bucketName = name === 'cellChanges'
|
|
86
|
+
? 'cellChanges'
|
|
87
|
+
: name === 'refiltersFromDataChange'
|
|
88
|
+
? 'refilters'
|
|
89
|
+
: name === 'flashes'
|
|
90
|
+
? 'flashes'
|
|
91
|
+
: null;
|
|
92
|
+
if (!bucketName) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const second = Math.floor(Date.now() / 1000);
|
|
96
|
+
let bucket = this.buckets.get(second);
|
|
97
|
+
if (!bucket) {
|
|
98
|
+
bucket = { cellChanges: 0, refilters: 0, flashes: 0 };
|
|
99
|
+
this.buckets.set(second, bucket);
|
|
100
|
+
for (const key of this.buckets.keys()) {
|
|
101
|
+
if (key < second - TICKING_WINDOW_SEC * 2) {
|
|
102
|
+
this.buckets.delete(key);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
bucket[bucketName] += amount;
|
|
107
|
+
}
|
|
108
|
+
snapshot(durationSec) {
|
|
109
|
+
const now = Math.floor(Date.now() / 1000);
|
|
110
|
+
const recent = { cellChanges: 0, refilters: 0, flashes: 0 };
|
|
111
|
+
for (let second = now - TICKING_WINDOW_SEC; second < now; second++) {
|
|
112
|
+
const bucket = this.buckets.get(second);
|
|
113
|
+
if (bucket) {
|
|
114
|
+
recent.cellChanges += bucket.cellChanges;
|
|
115
|
+
recent.refilters += bucket.refilters;
|
|
116
|
+
recent.flashes += bucket.flashes;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
durationSec: round(durationSec),
|
|
121
|
+
...this.totals,
|
|
122
|
+
recent: {
|
|
123
|
+
cellChangesPerSec: round(recent.cellChanges / TICKING_WINDOW_SEC),
|
|
124
|
+
refiltersPerSec: round(recent.refilters / TICKING_WINDOW_SEC),
|
|
125
|
+
flashesPerSec: round(recent.flashes / TICKING_WINDOW_SEC),
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
hasData() {
|
|
130
|
+
return Object.values(this.totals).some((value) => value > 0);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export class PerfRecorder {
|
|
134
|
+
store;
|
|
135
|
+
constructor(store) {
|
|
136
|
+
this.store = store;
|
|
137
|
+
}
|
|
138
|
+
add(kind, key, start, describe) {
|
|
139
|
+
const duration = performance.now() - start;
|
|
140
|
+
const hotPaths = this.store.hotPaths;
|
|
141
|
+
let stat = hotPaths.get(key);
|
|
142
|
+
if (!stat) {
|
|
143
|
+
if (hotPaths.size >= MAX_HOT_PATHS) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
stat = { key, kind, count: 0, totalMs: 0, maxMs: 0, ...(describe ? describe() : {}) };
|
|
147
|
+
hotPaths.set(key, stat);
|
|
148
|
+
}
|
|
149
|
+
stat.count++;
|
|
150
|
+
stat.totalMs += duration;
|
|
151
|
+
if (duration > stat.maxMs) {
|
|
152
|
+
stat.maxMs = duration;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
count(name, amount = 1) {
|
|
156
|
+
this.store.ticking.add(name, amount);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export class MemoryRecording {
|
|
160
|
+
readInventory;
|
|
161
|
+
intervalMs = HEAP_SAMPLE_INTERVAL_MS;
|
|
162
|
+
heapAt = 0;
|
|
163
|
+
inventoryAt = 0;
|
|
164
|
+
lastItems;
|
|
165
|
+
inventoryReads = { count: 0, totalMs: 0, maxMs: 0 };
|
|
166
|
+
recentInventoryReads = [];
|
|
167
|
+
heap = [];
|
|
168
|
+
inventory = [];
|
|
169
|
+
nextInventoryAt = 0;
|
|
170
|
+
constructor(readInventory) {
|
|
171
|
+
this.readInventory = readInventory;
|
|
172
|
+
}
|
|
173
|
+
sample(heap, now, force = false) {
|
|
174
|
+
if (heap) {
|
|
175
|
+
this.addHeapSample(heap);
|
|
176
|
+
}
|
|
177
|
+
this.sampleInventory(now, force);
|
|
178
|
+
}
|
|
179
|
+
addHeapSample(sample) {
|
|
180
|
+
const used = sample.usedJSHeapSize;
|
|
181
|
+
this.heapAt = Math.max(this.heapAt + 1, sample.timestamp);
|
|
182
|
+
const last = this.heap[this.heap.length - 1];
|
|
183
|
+
if (last && sample.timestamp - last.timestamp < this.intervalMs - HEAP_SAMPLE_INTERVAL_MS / 2) {
|
|
184
|
+
last.usedJSHeapSize = used;
|
|
185
|
+
last.usedMin = Math.min(last.usedMin, used);
|
|
186
|
+
last.usedMax = Math.max(last.usedMax, used);
|
|
187
|
+
last.totalJSHeapSize = sample.totalJSHeapSize;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
this.heap.push({
|
|
191
|
+
timestamp: sample.timestamp,
|
|
192
|
+
usedJSHeapSize: used,
|
|
193
|
+
usedMin: used,
|
|
194
|
+
usedMax: used,
|
|
195
|
+
totalJSHeapSize: sample.totalJSHeapSize,
|
|
196
|
+
});
|
|
197
|
+
if (this.heap.length > MAX_RECORDING_HEAP_POINTS) {
|
|
198
|
+
this.compactHeap();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
compactHeap() {
|
|
202
|
+
const merged = [];
|
|
203
|
+
for (let index = 0; index < this.heap.length; index += 2) {
|
|
204
|
+
const first = this.heap[index];
|
|
205
|
+
const second = this.heap[index + 1];
|
|
206
|
+
merged.push(second
|
|
207
|
+
? {
|
|
208
|
+
timestamp: first.timestamp,
|
|
209
|
+
usedJSHeapSize: second.usedJSHeapSize,
|
|
210
|
+
usedMin: Math.min(first.usedMin, second.usedMin),
|
|
211
|
+
usedMax: Math.max(first.usedMax, second.usedMax),
|
|
212
|
+
totalJSHeapSize: second.totalJSHeapSize,
|
|
213
|
+
}
|
|
214
|
+
: first);
|
|
215
|
+
}
|
|
216
|
+
this.heap = merged;
|
|
217
|
+
this.intervalMs *= 2;
|
|
218
|
+
}
|
|
219
|
+
sampleInventory(now, force) {
|
|
220
|
+
if (!force && now < this.nextInventoryAt) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
let items;
|
|
224
|
+
const start = performanceNow();
|
|
225
|
+
try {
|
|
226
|
+
items = this.readInventory();
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const duration = performanceNow() - start;
|
|
232
|
+
this.inventoryReads.count++;
|
|
233
|
+
this.inventoryReads.totalMs += duration;
|
|
234
|
+
this.inventoryReads.maxMs = Math.max(this.inventoryReads.maxMs, duration);
|
|
235
|
+
this.recentInventoryReads.push({ timestamp: toEpoch(start), duration });
|
|
236
|
+
if (this.recentInventoryReads.length > MAX_RECENT_INVENTORY_READS) {
|
|
237
|
+
this.recentInventoryReads.shift();
|
|
238
|
+
}
|
|
239
|
+
this.nextInventoryAt =
|
|
240
|
+
now + Math.max(INVENTORY_SAMPLE_INTERVAL_MS, duration * INVENTORY_COST_FACTOR);
|
|
241
|
+
this.inventoryAt = Math.max(this.inventoryAt + 1, now);
|
|
242
|
+
this.lastItems = { timestamp: now, items };
|
|
243
|
+
const sample = { timestamp: now, items: {} };
|
|
244
|
+
for (const item of items) {
|
|
245
|
+
if (item.count != null || item.approxBytes != null) {
|
|
246
|
+
sample.items[item.key] = { count: item.count, approxBytes: item.approxBytes };
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
this.inventory.push(sample);
|
|
250
|
+
if (this.inventory.length > MAX_INVENTORY_SAMPLES) {
|
|
251
|
+
this.inventory = [
|
|
252
|
+
this.inventory[0],
|
|
253
|
+
...this.inventory.slice(1).filter((_, index) => index % 2 === 1),
|
|
254
|
+
];
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
heapPoints() {
|
|
258
|
+
return this.heap.map((point) => ({ ...point }));
|
|
259
|
+
}
|
|
260
|
+
inventorySamples() {
|
|
261
|
+
return this.inventory.slice();
|
|
262
|
+
}
|
|
263
|
+
get heapSize() {
|
|
264
|
+
return this.heap.length;
|
|
265
|
+
}
|
|
266
|
+
get inventorySize() {
|
|
267
|
+
return this.inventory.length;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
export class PerfStore {
|
|
271
|
+
adaptableId;
|
|
272
|
+
measures = new RingBuffer(MAX_MEASURES);
|
|
273
|
+
hotPaths = new Map();
|
|
274
|
+
ticking = new TickingCounters();
|
|
275
|
+
labelStats = new Map();
|
|
276
|
+
recording = false;
|
|
277
|
+
recordingStartedAt;
|
|
278
|
+
recordingStoppedAt;
|
|
279
|
+
recordingHotPaths = false;
|
|
280
|
+
recordingOnLoad = false;
|
|
281
|
+
recorder = null;
|
|
282
|
+
recordingStopReason;
|
|
283
|
+
stopRecordingWhen;
|
|
284
|
+
pauseTracksWhen;
|
|
285
|
+
memory = null;
|
|
286
|
+
longFrameTotals = { count: 0, slowestMs: 0 };
|
|
287
|
+
constructor(adaptableId) {
|
|
288
|
+
this.adaptableId = adaptableId;
|
|
289
|
+
}
|
|
290
|
+
addMeasure(params) {
|
|
291
|
+
const { track, label, start, duration, details, tooltip } = params;
|
|
292
|
+
const timestamp = toEpoch(start);
|
|
293
|
+
this.measures.push({
|
|
294
|
+
timestamp,
|
|
295
|
+
duration: round(duration),
|
|
296
|
+
track,
|
|
297
|
+
label,
|
|
298
|
+
details: details?.length ? details : undefined,
|
|
299
|
+
tooltip,
|
|
300
|
+
});
|
|
301
|
+
const statsKey = `${track}::${label}`;
|
|
302
|
+
let stats = this.labelStats.get(statsKey);
|
|
303
|
+
if (!stats) {
|
|
304
|
+
if (this.labelStats.size >= MAX_LABEL_STATS) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
stats = {
|
|
308
|
+
track,
|
|
309
|
+
label,
|
|
310
|
+
count: 0,
|
|
311
|
+
totalMs: 0,
|
|
312
|
+
maxMs: 0,
|
|
313
|
+
lastMs: 0,
|
|
314
|
+
lastTimestamp: 0,
|
|
315
|
+
recent: [],
|
|
316
|
+
};
|
|
317
|
+
this.labelStats.set(statsKey, stats);
|
|
318
|
+
}
|
|
319
|
+
stats.count++;
|
|
320
|
+
stats.totalMs += duration;
|
|
321
|
+
stats.maxMs = Math.max(stats.maxMs, duration);
|
|
322
|
+
stats.lastMs = duration;
|
|
323
|
+
stats.lastTimestamp = timestamp;
|
|
324
|
+
stats.recent.push(duration);
|
|
325
|
+
if (stats.recent.length > MAX_LABEL_SAMPLES) {
|
|
326
|
+
stats.recent.shift();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
getLabelStats() {
|
|
330
|
+
return [...this.labelStats.values()].map((stats) => ({
|
|
331
|
+
track: stats.track,
|
|
332
|
+
label: stats.label,
|
|
333
|
+
count: stats.count,
|
|
334
|
+
totalMs: round(stats.totalMs),
|
|
335
|
+
avgMs: round(stats.totalMs / Math.max(1, stats.count)),
|
|
336
|
+
maxMs: round(stats.maxMs),
|
|
337
|
+
p95Ms: round(percentile(stats.recent, 95)),
|
|
338
|
+
lastMs: round(stats.lastMs),
|
|
339
|
+
lastTimestamp: stats.lastTimestamp,
|
|
340
|
+
}));
|
|
341
|
+
}
|
|
342
|
+
get recordingStopsWithDevTools() {
|
|
343
|
+
return this.stopRecordingWhen != null;
|
|
344
|
+
}
|
|
345
|
+
get writesTracks() {
|
|
346
|
+
return this.recording && this.pauseTracksWhen?.() !== true;
|
|
347
|
+
}
|
|
348
|
+
createMemory() {
|
|
349
|
+
const memory = new MemoryRecording(() => {
|
|
350
|
+
if (!INVENTORY_READER) {
|
|
351
|
+
throw new Error('no inventory reader');
|
|
352
|
+
}
|
|
353
|
+
return INVENTORY_READER(this.adaptableId);
|
|
354
|
+
});
|
|
355
|
+
memory.sample(readHeap(), Date.now(), true);
|
|
356
|
+
return memory;
|
|
357
|
+
}
|
|
358
|
+
startRecording(options) {
|
|
359
|
+
const wasRecording = this.recording;
|
|
360
|
+
const hotPaths = options?.hotPaths !== false;
|
|
361
|
+
this.dropRecordingResults();
|
|
362
|
+
this.memory = null;
|
|
363
|
+
this.memory = this.createMemory();
|
|
364
|
+
this.recording = true;
|
|
365
|
+
this.recordingStartedAt = Date.now();
|
|
366
|
+
this.recordingStoppedAt = undefined;
|
|
367
|
+
this.recordingStopReason = undefined;
|
|
368
|
+
this.recordingHotPaths = hotPaths;
|
|
369
|
+
this.recordingOnLoad = options?.onLoad === true;
|
|
370
|
+
this.stopRecordingWhen = options?.stopWhen;
|
|
371
|
+
this.pauseTracksWhen = options?.pauseTracksWhen;
|
|
372
|
+
this.recorder = hotPaths ? new PerfRecorder(this) : null;
|
|
373
|
+
updateSamplers();
|
|
374
|
+
if (!wasRecording) {
|
|
375
|
+
notifyRecordingChange(this.adaptableId);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
stopRecording(reason) {
|
|
379
|
+
if (!this.recording) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
PENDING_RECORD_ON_LOAD = null;
|
|
383
|
+
this.recording = false;
|
|
384
|
+
this.recorder = null;
|
|
385
|
+
this.recordingStoppedAt = Date.now();
|
|
386
|
+
this.recordingStopReason = reason;
|
|
387
|
+
this.stopRecordingWhen = undefined;
|
|
388
|
+
this.pauseTracksWhen = undefined;
|
|
389
|
+
updateSamplers();
|
|
390
|
+
this.memory?.sample(readHeap(), this.recordingStoppedAt, true);
|
|
391
|
+
notifyRecordingChange(this.adaptableId);
|
|
392
|
+
}
|
|
393
|
+
setStopWhen(stopWhen) {
|
|
394
|
+
if (this.recording) {
|
|
395
|
+
this.stopRecordingWhen = stopWhen;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
checkRecordingStop() {
|
|
399
|
+
if (this.recording && this.stopRecordingWhen?.()) {
|
|
400
|
+
this.stopRecording('devtools-closed');
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
clearRecording() {
|
|
404
|
+
this.dropRecordingResults();
|
|
405
|
+
if (this.recording) {
|
|
406
|
+
this.recordingStartedAt = Date.now();
|
|
407
|
+
this.recordingOnLoad = false;
|
|
408
|
+
this.memory = null;
|
|
409
|
+
this.memory = this.createMemory();
|
|
410
|
+
}
|
|
411
|
+
else {
|
|
412
|
+
this.memory = null;
|
|
413
|
+
this.recordingStartedAt = undefined;
|
|
414
|
+
this.recordingStoppedAt = undefined;
|
|
415
|
+
this.recordingStopReason = undefined;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
dropRecordingResults() {
|
|
419
|
+
this.hotPaths.clear();
|
|
420
|
+
this.longFrameTotals = { count: 0, slowestMs: 0 };
|
|
421
|
+
this.ticking = new TickingCounters();
|
|
422
|
+
this.measures.retain((measure) => measure.track === INITIALISATION_TRACK);
|
|
423
|
+
for (const [key, stats] of this.labelStats) {
|
|
424
|
+
if (stats.track !== INITIALISATION_TRACK) {
|
|
425
|
+
this.labelStats.delete(key);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (![...STORES.values()].some((store) => store !== this && store.recording)) {
|
|
429
|
+
LONG_FRAMES.clear();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
getData(cursor, profileTracksEnabled = false) {
|
|
433
|
+
const startedAt = this.recordingStartedAt;
|
|
434
|
+
const endedAt = this.recordingStoppedAt ?? Date.now();
|
|
435
|
+
const durationSec = startedAt ? (endedAt - startedAt) / 1000 : 0;
|
|
436
|
+
const memory = this.memory;
|
|
437
|
+
return {
|
|
438
|
+
adaptableId: this.adaptableId,
|
|
439
|
+
recording: this.recording,
|
|
440
|
+
recordingStartedAt: this.recordingStartedAt,
|
|
441
|
+
recordingStoppedAt: this.recordingStoppedAt,
|
|
442
|
+
recordingStopReason: this.recordingStopReason,
|
|
443
|
+
recordingHotPaths: startedAt ? this.recordingHotPaths : undefined,
|
|
444
|
+
recordingOnLoad: startedAt ? this.recordingOnLoad : undefined,
|
|
445
|
+
recordingStopsWithDevTools: this.recording ? this.recordingStopsWithDevTools : undefined,
|
|
446
|
+
longFrameTotals: startedAt
|
|
447
|
+
? { count: this.longFrameTotals.count, slowestMs: round(this.longFrameTotals.slowestMs) }
|
|
448
|
+
: undefined,
|
|
449
|
+
memory: memory
|
|
450
|
+
? {
|
|
451
|
+
intervalMs: memory.intervalMs,
|
|
452
|
+
heap: memory.heapAt > (cursor?.heap ?? 0) ? memory.heapPoints() : undefined,
|
|
453
|
+
inventory: memory.inventoryAt > (cursor?.inventory ?? 0) ? memory.inventorySamples() : undefined,
|
|
454
|
+
inventoryReads: {
|
|
455
|
+
count: memory.inventoryReads.count,
|
|
456
|
+
totalMs: round(memory.inventoryReads.totalMs),
|
|
457
|
+
maxMs: round(memory.inventoryReads.maxMs),
|
|
458
|
+
},
|
|
459
|
+
}
|
|
460
|
+
: undefined,
|
|
461
|
+
profileTracksEnabled,
|
|
462
|
+
supports: {
|
|
463
|
+
longAnimationFrame: supportsLongAnimationFrames(),
|
|
464
|
+
memory: supportsMemory(),
|
|
465
|
+
},
|
|
466
|
+
measures: this.measures.since(cursor?.measures ?? 0),
|
|
467
|
+
labelStats: this.getLabelStats(),
|
|
468
|
+
longFrames: startedAt == null
|
|
469
|
+
? []
|
|
470
|
+
: LONG_FRAMES.since(cursor?.longFrames ?? 0).filter((frame) => frame.timestamp + frame.duration >= startedAt &&
|
|
471
|
+
(this.recordingStoppedAt == null || frame.timestamp <= this.recordingStoppedAt)),
|
|
472
|
+
hotPaths: [...this.hotPaths.values()].map((stat) => ({
|
|
473
|
+
...stat,
|
|
474
|
+
totalMs: round(stat.totalMs),
|
|
475
|
+
maxMs: round(stat.maxMs),
|
|
476
|
+
})),
|
|
477
|
+
ticking: this.ticking.hasData() || this.recorder ? this.ticking.snapshot(durationSec) : undefined,
|
|
478
|
+
cursor: {
|
|
479
|
+
measures: this.measures.seq,
|
|
480
|
+
longFrames: LONG_FRAMES.seq,
|
|
481
|
+
heap: memory?.heapAt ?? 0,
|
|
482
|
+
inventory: memory?.inventoryAt ?? 0,
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
getBufferSizes() {
|
|
487
|
+
return {
|
|
488
|
+
measures: this.measures.size,
|
|
489
|
+
labelStats: this.labelStats.size,
|
|
490
|
+
hotPaths: this.hotPaths.size,
|
|
491
|
+
heapPoints: this.memory?.heapSize ?? 0,
|
|
492
|
+
inventorySamples: this.memory?.inventorySize ?? 0,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
const STORES = new Map();
|
|
497
|
+
let ACTIVE_RECORDINGS = 0;
|
|
498
|
+
let ACTIVE_PERF_RECORDINGS = 0;
|
|
499
|
+
let PENDING_RECORD_ON_LOAD = null;
|
|
500
|
+
let RECORDING_CHANGE_LISTENER = null;
|
|
501
|
+
export function onRecordingChange(listener) {
|
|
502
|
+
RECORDING_CHANGE_LISTENER = listener;
|
|
503
|
+
}
|
|
504
|
+
function notifyRecordingChange(adaptableId) {
|
|
505
|
+
RECORDING_CHANGE_LISTENER?.(adaptableId);
|
|
506
|
+
}
|
|
507
|
+
let INVENTORY_READER = null;
|
|
508
|
+
export function setInventoryReader(reader) {
|
|
509
|
+
INVENTORY_READER = reader;
|
|
510
|
+
}
|
|
511
|
+
export function setRecordOnLoadRequest(request) {
|
|
512
|
+
PENDING_RECORD_ON_LOAD = request;
|
|
513
|
+
}
|
|
514
|
+
export function getPerfStore(adaptableId) {
|
|
515
|
+
let store = STORES.get(adaptableId);
|
|
516
|
+
if (!store) {
|
|
517
|
+
store = new PerfStore(adaptableId);
|
|
518
|
+
STORES.set(adaptableId, store);
|
|
519
|
+
if (PENDING_RECORD_ON_LOAD) {
|
|
520
|
+
store.startRecording({ ...PENDING_RECORD_ON_LOAD, onLoad: true });
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
return store;
|
|
524
|
+
}
|
|
525
|
+
export function hasPerfStore(adaptableId) {
|
|
526
|
+
return STORES.has(adaptableId);
|
|
527
|
+
}
|
|
528
|
+
export function deletePerfStore(adaptableId) {
|
|
529
|
+
const store = STORES.get(adaptableId);
|
|
530
|
+
if (store) {
|
|
531
|
+
STORES.delete(adaptableId);
|
|
532
|
+
store.stopRecording();
|
|
533
|
+
updateSamplers();
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
export function isRecordingTracks(adaptableId) {
|
|
537
|
+
if (ACTIVE_PERF_RECORDINGS === 0 || !adaptableId) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
return STORES.get(adaptableId)?.writesTracks === true;
|
|
541
|
+
}
|
|
542
|
+
export function isRecordingPerformance(adaptableId) {
|
|
543
|
+
if (ACTIVE_PERF_RECORDINGS === 0 || !adaptableId) {
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
return STORES.get(adaptableId)?.recording === true;
|
|
547
|
+
}
|
|
548
|
+
export function shouldKeepOperation(adaptableId, track) {
|
|
549
|
+
return track === INITIALISATION_TRACK || isRecordingPerformance(adaptableId);
|
|
550
|
+
}
|
|
551
|
+
export function getPerfRecorder(adaptableId) {
|
|
552
|
+
if (ACTIVE_RECORDINGS === 0 || !adaptableId) {
|
|
553
|
+
return null;
|
|
554
|
+
}
|
|
555
|
+
return STORES.get(adaptableId)?.recorder ?? null;
|
|
556
|
+
}
|
|
557
|
+
export function isPerfRecording(adaptableId) {
|
|
558
|
+
return getPerfRecorder(adaptableId) != null;
|
|
559
|
+
}
|
|
560
|
+
const LONG_FRAMES = new RingBuffer(MAX_LONG_FRAMES);
|
|
561
|
+
let longFrameObserver = null;
|
|
562
|
+
let heapTimer = null;
|
|
563
|
+
function getPerformanceMemory() {
|
|
564
|
+
if (typeof performance === 'undefined') {
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
const memory = performance.memory;
|
|
568
|
+
return memory && typeof memory.usedJSHeapSize === 'number' ? memory : undefined;
|
|
569
|
+
}
|
|
570
|
+
export function supportsMemory() {
|
|
571
|
+
return getPerformanceMemory() != null;
|
|
572
|
+
}
|
|
573
|
+
function performanceNow() {
|
|
574
|
+
return typeof performance !== 'undefined' ? performance.now() : Date.now();
|
|
575
|
+
}
|
|
576
|
+
export function readHeap() {
|
|
577
|
+
const memory = getPerformanceMemory();
|
|
578
|
+
if (!memory) {
|
|
579
|
+
return undefined;
|
|
580
|
+
}
|
|
581
|
+
return {
|
|
582
|
+
timestamp: Date.now(),
|
|
583
|
+
usedJSHeapSize: memory.usedJSHeapSize,
|
|
584
|
+
totalJSHeapSize: memory.totalJSHeapSize,
|
|
585
|
+
jsHeapSizeLimit: memory.jsHeapSizeLimit,
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
export function supportsLongAnimationFrames() {
|
|
589
|
+
return (typeof PerformanceObserver !== 'undefined' &&
|
|
590
|
+
Array.isArray(PerformanceObserver.supportedEntryTypes) &&
|
|
591
|
+
PerformanceObserver.supportedEntryTypes.includes('long-animation-frame'));
|
|
592
|
+
}
|
|
593
|
+
function shortenSourceUrl(url) {
|
|
594
|
+
if (!url) {
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
try {
|
|
598
|
+
const parsed = new URL(url);
|
|
599
|
+
return parsed.pathname.split('/').filter(Boolean).slice(-2).join('/') || parsed.host;
|
|
600
|
+
}
|
|
601
|
+
catch {
|
|
602
|
+
return url;
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
function findOverlappingOperations(start, end) {
|
|
606
|
+
const result = [];
|
|
607
|
+
for (const store of STORES.values()) {
|
|
608
|
+
const measures = store.measures.all();
|
|
609
|
+
for (let index = measures.length - 1; index >= 0; index--) {
|
|
610
|
+
const measure = measures[index];
|
|
611
|
+
const measureEnd = measure.timestamp + measure.duration;
|
|
612
|
+
if (measureEnd < start - 1000) {
|
|
613
|
+
break;
|
|
614
|
+
}
|
|
615
|
+
if (measure.timestamp <= end && measureEnd >= start) {
|
|
616
|
+
const prefix = STORES.size > 1 ? `${store.adaptableId} ` : '';
|
|
617
|
+
result.unshift(`${prefix}${measure.track}: ${measure.label} (${Math.round(measure.duration)}ms)`);
|
|
618
|
+
}
|
|
619
|
+
if (result.length >= 8) {
|
|
620
|
+
break;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
for (const read of store.memory?.recentInventoryReads ?? []) {
|
|
624
|
+
if (read.timestamp <= end && read.timestamp + read.duration >= start) {
|
|
625
|
+
result.push(`DevTools: reading structure sizes (${Math.round(read.duration)}ms)`);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return result;
|
|
630
|
+
}
|
|
631
|
+
function onLongFrames(list) {
|
|
632
|
+
for (const entry of list.getEntries()) {
|
|
633
|
+
const timestamp = toEpoch(entry.startTime);
|
|
634
|
+
const scripts = (entry.scripts ?? [])
|
|
635
|
+
.slice()
|
|
636
|
+
.sort((a, b) => b.duration - a.duration)
|
|
637
|
+
.slice(0, MAX_LONG_FRAME_SCRIPTS)
|
|
638
|
+
.map((script) => ({
|
|
639
|
+
invoker: script.invoker || undefined,
|
|
640
|
+
invokerType: script.invokerType || undefined,
|
|
641
|
+
sourceURL: shortenSourceUrl(script.sourceURL),
|
|
642
|
+
sourceFunctionName: script.sourceFunctionName || undefined,
|
|
643
|
+
duration: round(script.duration),
|
|
644
|
+
}));
|
|
645
|
+
for (const store of STORES.values()) {
|
|
646
|
+
if (store.recording) {
|
|
647
|
+
store.longFrameTotals.count++;
|
|
648
|
+
store.longFrameTotals.slowestMs = Math.max(store.longFrameTotals.slowestMs, entry.duration);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
LONG_FRAMES.push({
|
|
652
|
+
timestamp,
|
|
653
|
+
duration: round(entry.duration),
|
|
654
|
+
blockingDuration: round(entry.blockingDuration ?? 0),
|
|
655
|
+
scripts,
|
|
656
|
+
adaptableOperations: findOverlappingOperations(timestamp, timestamp + entry.duration),
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function sample() {
|
|
661
|
+
const now = Date.now();
|
|
662
|
+
const heap = readHeap();
|
|
663
|
+
for (const store of STORES.values()) {
|
|
664
|
+
if (store.recording) {
|
|
665
|
+
store.memory?.sample(heap, now);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function onSamplerTick() {
|
|
670
|
+
for (const store of STORES.values()) {
|
|
671
|
+
store.checkRecordingStop();
|
|
672
|
+
}
|
|
673
|
+
if (updateSamplers()) {
|
|
674
|
+
sample();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function updateSamplers() {
|
|
678
|
+
let hotPathRecordings = 0;
|
|
679
|
+
let perfRecordings = 0;
|
|
680
|
+
for (const store of STORES.values()) {
|
|
681
|
+
if (store.recording) {
|
|
682
|
+
perfRecordings++;
|
|
683
|
+
}
|
|
684
|
+
if (store.recorder) {
|
|
685
|
+
hotPathRecordings++;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
ACTIVE_RECORDINGS = hotPathRecordings;
|
|
689
|
+
ACTIVE_PERF_RECORDINGS = perfRecordings;
|
|
690
|
+
const recording = perfRecordings > 0;
|
|
691
|
+
if (recording) {
|
|
692
|
+
if (!longFrameObserver && supportsLongAnimationFrames()) {
|
|
693
|
+
try {
|
|
694
|
+
longFrameObserver = new PerformanceObserver(onLongFrames);
|
|
695
|
+
longFrameObserver.observe({ type: 'long-animation-frame', buffered: false });
|
|
696
|
+
}
|
|
697
|
+
catch {
|
|
698
|
+
longFrameObserver = null;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
if (!heapTimer) {
|
|
702
|
+
heapTimer = setInterval(onSamplerTick, HEAP_SAMPLE_INTERVAL_MS);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
else {
|
|
706
|
+
longFrameObserver?.disconnect();
|
|
707
|
+
longFrameObserver = null;
|
|
708
|
+
if (heapTimer) {
|
|
709
|
+
clearInterval(heapTimer);
|
|
710
|
+
heapTimer = null;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return recording;
|
|
714
|
+
}
|
|
715
|
+
export function getPageBufferSizes() {
|
|
716
|
+
return { longFrames: LONG_FRAMES.size };
|
|
717
|
+
}
|