@grafana/scenes 6.28.3--canary.1195.16590049708.0 → 6.28.4--canary.1198.16595564474.0
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 +12 -0
- package/dist/esm/behaviors/SceneQueryController.js +15 -10
- package/dist/esm/behaviors/SceneQueryController.js.map +1 -1
- package/dist/esm/behaviors/SceneRenderProfiler.js +19 -20
- package/dist/esm/behaviors/SceneRenderProfiler.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.js +202 -196
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -607,246 +607,77 @@ var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Ca
|
|
|
607
607
|
var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
608
608
|
var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
609
609
|
var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
|
|
610
|
-
var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
|
|
611
|
-
const POST_STORM_WINDOW = 2e3;
|
|
612
|
-
const SPAN_THRESHOLD = 30;
|
|
613
|
-
class SceneRenderProfiler {
|
|
614
|
-
constructor(queryController) {
|
|
615
|
-
this.queryController = queryController;
|
|
616
|
-
__privateAdd$3(this, _profileInProgress, null);
|
|
617
|
-
__privateAdd$3(this, _profileStartTs, null);
|
|
618
|
-
__privateAdd$3(this, _trailAnimationFrameId, null);
|
|
619
|
-
// Will keep measured lengths trailing frames
|
|
620
|
-
__privateAdd$3(this, _recordedTrailingSpans, []);
|
|
621
|
-
this.lastFrameTime = 0;
|
|
622
|
-
this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
|
|
623
|
-
const currentFrameTime = performance.now();
|
|
624
|
-
const frameLength = currentFrameTime - lastFrameTime;
|
|
625
|
-
__privateGet$3(this, _recordedTrailingSpans).push(frameLength);
|
|
626
|
-
if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
|
|
627
|
-
__privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
|
|
628
|
-
() => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
|
|
629
|
-
));
|
|
630
|
-
} else {
|
|
631
|
-
const slowFrames = processRecordedSpans(__privateGet$3(this, _recordedTrailingSpans));
|
|
632
|
-
const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
|
|
633
|
-
writeSceneLog(
|
|
634
|
-
this.constructor.name,
|
|
635
|
-
"Profile tail recorded, slow frames duration:",
|
|
636
|
-
slowFramesTime,
|
|
637
|
-
slowFrames,
|
|
638
|
-
__privateGet$3(this, _profileInProgress)
|
|
639
|
-
);
|
|
640
|
-
__privateSet$3(this, _recordedTrailingSpans, []);
|
|
641
|
-
const profileDuration = measurementStartTs - profileStartTs;
|
|
642
|
-
writeSceneLog(
|
|
643
|
-
this.constructor.name,
|
|
644
|
-
"Stoped recording, total measured time (network included):",
|
|
645
|
-
profileDuration + slowFramesTime
|
|
646
|
-
);
|
|
647
|
-
__privateSet$3(this, _trailAnimationFrameId, null);
|
|
648
|
-
const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
|
|
649
|
-
performance.measure(`DashboardInteraction ${__privateGet$3(this, _profileInProgress).origin}`, {
|
|
650
|
-
start: profileStartTs,
|
|
651
|
-
end: profileEndTs
|
|
652
|
-
});
|
|
653
|
-
const networkDuration = captureNetwork(profileStartTs, profileEndTs);
|
|
654
|
-
if (this.queryController.state.onProfileComplete) {
|
|
655
|
-
this.queryController.state.onProfileComplete({
|
|
656
|
-
origin: __privateGet$3(this, _profileInProgress).origin,
|
|
657
|
-
crumbs: __privateGet$3(this, _profileInProgress).crumbs,
|
|
658
|
-
duration: profileDuration + slowFramesTime,
|
|
659
|
-
networkDuration,
|
|
660
|
-
// @ts-ignore
|
|
661
|
-
jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
|
|
662
|
-
// @ts-ignore
|
|
663
|
-
usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
|
|
664
|
-
// @ts-ignore
|
|
665
|
-
totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
|
|
666
|
-
});
|
|
667
|
-
__privateSet$3(this, _profileInProgress, null);
|
|
668
|
-
}
|
|
669
|
-
if (window.__runs) {
|
|
670
|
-
window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
|
|
671
|
-
`;
|
|
672
|
-
} else {
|
|
673
|
-
window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
|
|
674
|
-
`;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
}
|
|
679
|
-
startProfile(name) {
|
|
680
|
-
if (__privateGet$3(this, _profileInProgress)) {
|
|
681
|
-
if (__privateGet$3(this, _trailAnimationFrameId)) {
|
|
682
|
-
cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
|
|
683
|
-
__privateSet$3(this, _trailAnimationFrameId, null);
|
|
684
|
-
writeSceneLog(this.constructor.name, "New profile: Stopped recording frames ");
|
|
685
|
-
__privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
|
|
686
|
-
__privateSet$3(this, _profileStartTs, performance.now());
|
|
687
|
-
writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
|
|
688
|
-
} else {
|
|
689
|
-
this.addCrumb(name);
|
|
690
|
-
}
|
|
691
|
-
} else {
|
|
692
|
-
__privateSet$3(this, _profileInProgress, { origin: name, crumbs: [] });
|
|
693
|
-
__privateSet$3(this, _profileStartTs, performance.now());
|
|
694
|
-
writeSceneLog(this.constructor.name, "Profile started:", __privateGet$3(this, _profileInProgress), __privateGet$3(this, _profileStartTs));
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
recordProfileTail(measurementStartTime, profileStartTs) {
|
|
698
|
-
__privateSet$3(this, _trailAnimationFrameId, requestAnimationFrame(
|
|
699
|
-
() => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
|
|
700
|
-
));
|
|
701
|
-
}
|
|
702
|
-
tryCompletingProfile() {
|
|
703
|
-
writeSceneLog(this.constructor.name, "Trying to complete profile", __privateGet$3(this, _profileInProgress));
|
|
704
|
-
if (this.queryController.runningQueriesCount() === 0 && __privateGet$3(this, _profileInProgress)) {
|
|
705
|
-
writeSceneLog(this.constructor.name, "All queries completed, stopping profile");
|
|
706
|
-
this.recordProfileTail(performance.now(), __privateGet$3(this, _profileStartTs));
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
isTailRecording() {
|
|
710
|
-
return Boolean(__privateGet$3(this, _trailAnimationFrameId));
|
|
711
|
-
}
|
|
712
|
-
cancelTailRecording() {
|
|
713
|
-
if (__privateGet$3(this, _trailAnimationFrameId)) {
|
|
714
|
-
cancelAnimationFrame(__privateGet$3(this, _trailAnimationFrameId));
|
|
715
|
-
__privateSet$3(this, _trailAnimationFrameId, null);
|
|
716
|
-
writeSceneLog(this.constructor.name, "Cancelled recording frames, new profile started");
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
addCrumb(crumb) {
|
|
720
|
-
if (__privateGet$3(this, _profileInProgress)) {
|
|
721
|
-
writeSceneLog(this.constructor.name, "Adding crumb:", crumb);
|
|
722
|
-
__privateGet$3(this, _profileInProgress).crumbs.push(crumb);
|
|
723
|
-
}
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
_profileInProgress = new WeakMap();
|
|
727
|
-
_profileStartTs = new WeakMap();
|
|
728
|
-
_trailAnimationFrameId = new WeakMap();
|
|
729
|
-
_recordedTrailingSpans = new WeakMap();
|
|
730
|
-
function processRecordedSpans(spans) {
|
|
731
|
-
for (let i = spans.length - 1; i >= 0; i--) {
|
|
732
|
-
if (spans[i] > SPAN_THRESHOLD) {
|
|
733
|
-
return spans.slice(0, i + 1);
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
return [spans[0]];
|
|
737
|
-
}
|
|
738
|
-
function captureNetwork(startTs, endTs) {
|
|
739
|
-
const entries = performance.getEntriesByType("resource");
|
|
740
|
-
performance.clearResourceTimings();
|
|
741
|
-
const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
|
|
742
|
-
for (const entry of networkEntries) {
|
|
743
|
-
performance.measure("Network entry " + entry.name, {
|
|
744
|
-
start: entry.startTime,
|
|
745
|
-
end: entry.responseEnd
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
return calculateNetworkTime(networkEntries);
|
|
749
|
-
}
|
|
750
|
-
function calculateNetworkTime(requests) {
|
|
751
|
-
if (requests.length === 0) {
|
|
752
|
-
return 0;
|
|
753
|
-
}
|
|
754
|
-
requests.sort((a, b) => a.startTime - b.startTime);
|
|
755
|
-
let totalNetworkTime = 0;
|
|
756
|
-
let currentStart = requests[0].startTime;
|
|
757
|
-
let currentEnd = requests[0].responseEnd;
|
|
758
|
-
for (let i = 1; i < requests.length; i++) {
|
|
759
|
-
if (requests[i].startTime <= currentEnd) {
|
|
760
|
-
currentEnd = Math.max(currentEnd, requests[i].responseEnd);
|
|
761
|
-
} else {
|
|
762
|
-
totalNetworkTime += currentEnd - currentStart;
|
|
763
|
-
currentStart = requests[i].startTime;
|
|
764
|
-
currentEnd = requests[i].responseEnd;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
totalNetworkTime += currentEnd - currentStart;
|
|
768
|
-
return totalNetworkTime;
|
|
769
|
-
}
|
|
770
|
-
const REFRESH_INTERACTION = "refresh";
|
|
771
|
-
const TIME_RANGE_CHANGE_INTERACTION = "time_range_change";
|
|
772
|
-
const FILTER_REMOVED_INTERACTION = "filter_removed";
|
|
773
|
-
const FILTER_CHANGED_INTERACTION = "filter_changed";
|
|
774
|
-
const FILTER_RESTORED_INTERACTION = "filter_restored";
|
|
775
|
-
const VARIABLE_VALUE_CHANGED_INTERACTION = "variable_value_changed";
|
|
776
|
-
const SCOPES_CHANGED_INTERACTION = "scopes_changed";
|
|
777
|
-
|
|
778
|
-
var __typeError$2 = (msg) => {
|
|
779
|
-
throw TypeError(msg);
|
|
780
|
-
};
|
|
781
|
-
var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
|
|
782
|
-
var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
783
|
-
var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
784
|
-
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
|
|
785
610
|
var _running, _tryCompleteProfileFrameId;
|
|
786
611
|
function isQueryController(s) {
|
|
787
612
|
return "isQueryController" in s;
|
|
788
613
|
}
|
|
789
614
|
class SceneQueryController extends SceneObjectBase {
|
|
790
|
-
constructor(state = {}) {
|
|
615
|
+
constructor(state = {}, profiler) {
|
|
791
616
|
super({ ...state, isRunning: false });
|
|
617
|
+
this.profiler = profiler;
|
|
792
618
|
this.isQueryController = true;
|
|
793
|
-
this
|
|
794
|
-
__privateAdd$
|
|
795
|
-
__privateAdd$2(this, _tryCompleteProfileFrameId, null);
|
|
619
|
+
__privateAdd$3(this, _running, /* @__PURE__ */ new Set());
|
|
620
|
+
__privateAdd$3(this, _tryCompleteProfileFrameId, null);
|
|
796
621
|
this.runningQueriesCount = () => {
|
|
797
|
-
return __privateGet$
|
|
622
|
+
return __privateGet$3(this, _running).size;
|
|
798
623
|
};
|
|
624
|
+
if (profiler) {
|
|
625
|
+
this.profiler = profiler;
|
|
626
|
+
profiler.setQueryController(this);
|
|
627
|
+
}
|
|
799
628
|
this.addActivationHandler(() => {
|
|
800
|
-
return () => __privateGet$
|
|
629
|
+
return () => __privateGet$3(this, _running).clear();
|
|
801
630
|
});
|
|
802
631
|
}
|
|
803
632
|
startProfile(name) {
|
|
633
|
+
var _a;
|
|
804
634
|
if (!this.state.enableProfiling) {
|
|
805
635
|
return;
|
|
806
636
|
}
|
|
807
|
-
this.profiler.startProfile(name);
|
|
637
|
+
(_a = this.profiler) == null ? void 0 : _a.startProfile(name);
|
|
808
638
|
}
|
|
809
639
|
queryStarted(entry) {
|
|
810
|
-
__privateGet$
|
|
640
|
+
__privateGet$3(this, _running).add(entry);
|
|
811
641
|
this.changeRunningQueryCount(1, entry);
|
|
812
642
|
if (!this.state.isRunning) {
|
|
813
643
|
this.setState({ isRunning: true });
|
|
814
644
|
}
|
|
815
645
|
}
|
|
816
646
|
queryCompleted(entry) {
|
|
817
|
-
if (!__privateGet$
|
|
647
|
+
if (!__privateGet$3(this, _running).has(entry)) {
|
|
818
648
|
return;
|
|
819
649
|
}
|
|
820
|
-
__privateGet$
|
|
650
|
+
__privateGet$3(this, _running).delete(entry);
|
|
821
651
|
this.changeRunningQueryCount(-1);
|
|
822
|
-
if (__privateGet$
|
|
652
|
+
if (__privateGet$3(this, _running).size === 0) {
|
|
823
653
|
this.setState({ isRunning: false });
|
|
824
654
|
}
|
|
825
655
|
}
|
|
826
656
|
changeRunningQueryCount(dir, entry) {
|
|
827
|
-
var _a;
|
|
657
|
+
var _a, _b, _c, _d;
|
|
828
658
|
window.__grafanaRunningQueryCount = ((_a = window.__grafanaRunningQueryCount) != null ? _a : 0) + dir;
|
|
829
659
|
if (dir === 1 && this.state.enableProfiling) {
|
|
830
660
|
if (entry) {
|
|
831
|
-
this.profiler.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
|
|
661
|
+
(_b = this.profiler) == null ? void 0 : _b.addCrumb(`${entry.origin.constructor.name}/${entry.type}`);
|
|
832
662
|
}
|
|
833
|
-
if (this.profiler.isTailRecording()) {
|
|
834
|
-
writeSceneLog(
|
|
835
|
-
this.profiler.cancelTailRecording();
|
|
663
|
+
if ((_c = this.profiler) == null ? void 0 : _c.isTailRecording()) {
|
|
664
|
+
writeSceneLog("SceneQueryController", "New query started, cancelling tail recording");
|
|
665
|
+
(_d = this.profiler) == null ? void 0 : _d.cancelTailRecording();
|
|
836
666
|
}
|
|
837
667
|
}
|
|
838
668
|
if (this.state.enableProfiling) {
|
|
839
|
-
if (__privateGet$
|
|
840
|
-
cancelAnimationFrame(__privateGet$
|
|
669
|
+
if (__privateGet$3(this, _tryCompleteProfileFrameId)) {
|
|
670
|
+
cancelAnimationFrame(__privateGet$3(this, _tryCompleteProfileFrameId));
|
|
841
671
|
}
|
|
842
|
-
__privateSet$
|
|
843
|
-
|
|
672
|
+
__privateSet$3(this, _tryCompleteProfileFrameId, requestAnimationFrame(() => {
|
|
673
|
+
var _a2;
|
|
674
|
+
(_a2 = this.profiler) == null ? void 0 : _a2.tryCompletingProfile();
|
|
844
675
|
}));
|
|
845
676
|
}
|
|
846
677
|
}
|
|
847
678
|
cancelAll() {
|
|
848
679
|
var _a;
|
|
849
|
-
for (const entry of __privateGet$
|
|
680
|
+
for (const entry of __privateGet$3(this, _running).values()) {
|
|
850
681
|
(_a = entry.cancel) == null ? void 0 : _a.call(entry);
|
|
851
682
|
}
|
|
852
683
|
}
|
|
@@ -1016,6 +847,180 @@ function isValid$1(value, roundUp, timeZone) {
|
|
|
1016
847
|
return parsed.isValid();
|
|
1017
848
|
}
|
|
1018
849
|
|
|
850
|
+
var __typeError$2 = (msg) => {
|
|
851
|
+
throw TypeError(msg);
|
|
852
|
+
};
|
|
853
|
+
var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
|
|
854
|
+
var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
855
|
+
var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
856
|
+
var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
|
|
857
|
+
var _profileInProgress, _profileStartTs, _trailAnimationFrameId, _recordedTrailingSpans;
|
|
858
|
+
const POST_STORM_WINDOW = 2e3;
|
|
859
|
+
const SPAN_THRESHOLD = 30;
|
|
860
|
+
class SceneRenderProfiler {
|
|
861
|
+
constructor(queryController) {
|
|
862
|
+
this.queryController = queryController;
|
|
863
|
+
__privateAdd$2(this, _profileInProgress, null);
|
|
864
|
+
__privateAdd$2(this, _profileStartTs, null);
|
|
865
|
+
__privateAdd$2(this, _trailAnimationFrameId, null);
|
|
866
|
+
// Will keep measured lengths trailing frames
|
|
867
|
+
__privateAdd$2(this, _recordedTrailingSpans, []);
|
|
868
|
+
this.lastFrameTime = 0;
|
|
869
|
+
this.measureTrailingFrames = (measurementStartTs, lastFrameTime, profileStartTs) => {
|
|
870
|
+
var _a;
|
|
871
|
+
const currentFrameTime = performance.now();
|
|
872
|
+
const frameLength = currentFrameTime - lastFrameTime;
|
|
873
|
+
__privateGet$2(this, _recordedTrailingSpans).push(frameLength);
|
|
874
|
+
if (currentFrameTime - measurementStartTs < POST_STORM_WINDOW) {
|
|
875
|
+
if (__privateGet$2(this, _profileInProgress)) {
|
|
876
|
+
__privateSet$2(this, _trailAnimationFrameId, requestAnimationFrame(
|
|
877
|
+
() => this.measureTrailingFrames(measurementStartTs, currentFrameTime, profileStartTs)
|
|
878
|
+
));
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
const slowFrames = processRecordedSpans(__privateGet$2(this, _recordedTrailingSpans));
|
|
882
|
+
const slowFramesTime = slowFrames.reduce((acc, val) => acc + val, 0);
|
|
883
|
+
writeSceneLog(
|
|
884
|
+
this.constructor.name,
|
|
885
|
+
"Profile tail recorded, slow frames duration:",
|
|
886
|
+
slowFramesTime,
|
|
887
|
+
slowFrames,
|
|
888
|
+
__privateGet$2(this, _profileInProgress)
|
|
889
|
+
);
|
|
890
|
+
__privateSet$2(this, _recordedTrailingSpans, []);
|
|
891
|
+
const profileDuration = measurementStartTs - profileStartTs;
|
|
892
|
+
writeSceneLog(
|
|
893
|
+
this.constructor.name,
|
|
894
|
+
"Stoped recording, total measured time (network included):",
|
|
895
|
+
profileDuration + slowFramesTime
|
|
896
|
+
);
|
|
897
|
+
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
898
|
+
const profileEndTs = profileStartTs + profileDuration + slowFramesTime;
|
|
899
|
+
performance.measure(`DashboardInteraction ${__privateGet$2(this, _profileInProgress).origin}`, {
|
|
900
|
+
start: profileStartTs,
|
|
901
|
+
end: profileEndTs
|
|
902
|
+
});
|
|
903
|
+
const networkDuration = captureNetwork(profileStartTs, profileEndTs);
|
|
904
|
+
if ((_a = this.queryController) == null ? void 0 : _a.state.onProfileComplete) {
|
|
905
|
+
this.queryController.state.onProfileComplete({
|
|
906
|
+
origin: __privateGet$2(this, _profileInProgress).origin,
|
|
907
|
+
crumbs: __privateGet$2(this, _profileInProgress).crumbs,
|
|
908
|
+
duration: profileDuration + slowFramesTime,
|
|
909
|
+
networkDuration,
|
|
910
|
+
// @ts-ignore
|
|
911
|
+
jsHeapSizeLimit: performance.memory ? performance.memory.jsHeapSizeLimit : 0,
|
|
912
|
+
// @ts-ignore
|
|
913
|
+
usedJSHeapSize: performance.memory ? performance.memory.usedJSHeapSize : 0,
|
|
914
|
+
// @ts-ignore
|
|
915
|
+
totalJSHeapSize: performance.memory ? performance.memory.totalJSHeapSize : 0
|
|
916
|
+
});
|
|
917
|
+
__privateSet$2(this, _profileInProgress, null);
|
|
918
|
+
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
919
|
+
}
|
|
920
|
+
if (window.__runs) {
|
|
921
|
+
window.__runs += `${Date.now()}, ${profileDuration + slowFramesTime}
|
|
922
|
+
`;
|
|
923
|
+
} else {
|
|
924
|
+
window.__runs = `${Date.now()}, ${profileDuration + slowFramesTime}
|
|
925
|
+
`;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
setQueryController(queryController) {
|
|
931
|
+
this.queryController = queryController;
|
|
932
|
+
}
|
|
933
|
+
startProfile(name) {
|
|
934
|
+
if (__privateGet$2(this, _profileInProgress)) {
|
|
935
|
+
this.addCrumb(name);
|
|
936
|
+
} else {
|
|
937
|
+
__privateSet$2(this, _profileInProgress, { origin: name, crumbs: [] });
|
|
938
|
+
__privateSet$2(this, _profileStartTs, performance.now());
|
|
939
|
+
writeSceneLog("SceneRenderProfiler", "Profile started:", __privateGet$2(this, _profileInProgress), __privateGet$2(this, _profileStartTs));
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
recordProfileTail(measurementStartTime, profileStartTs) {
|
|
943
|
+
__privateSet$2(this, _trailAnimationFrameId, requestAnimationFrame(
|
|
944
|
+
() => this.measureTrailingFrames(measurementStartTime, measurementStartTime, profileStartTs)
|
|
945
|
+
));
|
|
946
|
+
}
|
|
947
|
+
tryCompletingProfile() {
|
|
948
|
+
var _a;
|
|
949
|
+
writeSceneLog("SceneRenderProfiler", "Trying to complete profile", __privateGet$2(this, _profileInProgress));
|
|
950
|
+
if (((_a = this.queryController) == null ? void 0 : _a.runningQueriesCount()) === 0 && __privateGet$2(this, _profileInProgress)) {
|
|
951
|
+
writeSceneLog("SceneRenderProfiler", "All queries completed, stopping profile");
|
|
952
|
+
this.recordProfileTail(performance.now(), __privateGet$2(this, _profileStartTs));
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
isTailRecording() {
|
|
956
|
+
return Boolean(__privateGet$2(this, _trailAnimationFrameId));
|
|
957
|
+
}
|
|
958
|
+
cancelTailRecording() {
|
|
959
|
+
if (__privateGet$2(this, _trailAnimationFrameId)) {
|
|
960
|
+
cancelAnimationFrame(__privateGet$2(this, _trailAnimationFrameId));
|
|
961
|
+
__privateSet$2(this, _trailAnimationFrameId, null);
|
|
962
|
+
writeSceneLog("SceneRenderProfiler", "Cancelled recording frames, new profile started");
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
addCrumb(crumb) {
|
|
966
|
+
if (__privateGet$2(this, _profileInProgress)) {
|
|
967
|
+
writeSceneLog("SceneRenderProfiler", "Adding crumb:", crumb);
|
|
968
|
+
__privateGet$2(this, _profileInProgress).crumbs.push(crumb);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
_profileInProgress = new WeakMap();
|
|
973
|
+
_profileStartTs = new WeakMap();
|
|
974
|
+
_trailAnimationFrameId = new WeakMap();
|
|
975
|
+
_recordedTrailingSpans = new WeakMap();
|
|
976
|
+
function processRecordedSpans(spans) {
|
|
977
|
+
for (let i = spans.length - 1; i >= 0; i--) {
|
|
978
|
+
if (spans[i] > SPAN_THRESHOLD) {
|
|
979
|
+
return spans.slice(0, i + 1);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return [spans[0]];
|
|
983
|
+
}
|
|
984
|
+
function captureNetwork(startTs, endTs) {
|
|
985
|
+
const entries = performance.getEntriesByType("resource");
|
|
986
|
+
performance.clearResourceTimings();
|
|
987
|
+
const networkEntries = entries.filter((entry) => entry.startTime >= startTs && entry.startTime <= endTs);
|
|
988
|
+
for (const entry of networkEntries) {
|
|
989
|
+
performance.measure("Network entry " + entry.name, {
|
|
990
|
+
start: entry.startTime,
|
|
991
|
+
end: entry.responseEnd
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
return calculateNetworkTime(networkEntries);
|
|
995
|
+
}
|
|
996
|
+
function calculateNetworkTime(requests) {
|
|
997
|
+
if (requests.length === 0) {
|
|
998
|
+
return 0;
|
|
999
|
+
}
|
|
1000
|
+
requests.sort((a, b) => a.startTime - b.startTime);
|
|
1001
|
+
let totalNetworkTime = 0;
|
|
1002
|
+
let currentStart = requests[0].startTime;
|
|
1003
|
+
let currentEnd = requests[0].responseEnd;
|
|
1004
|
+
for (let i = 1; i < requests.length; i++) {
|
|
1005
|
+
if (requests[i].startTime <= currentEnd) {
|
|
1006
|
+
currentEnd = Math.max(currentEnd, requests[i].responseEnd);
|
|
1007
|
+
} else {
|
|
1008
|
+
totalNetworkTime += currentEnd - currentStart;
|
|
1009
|
+
currentStart = requests[i].startTime;
|
|
1010
|
+
currentEnd = requests[i].responseEnd;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
totalNetworkTime += currentEnd - currentStart;
|
|
1014
|
+
return totalNetworkTime;
|
|
1015
|
+
}
|
|
1016
|
+
const REFRESH_INTERACTION = "refresh";
|
|
1017
|
+
const TIME_RANGE_CHANGE_INTERACTION = "time_range_change";
|
|
1018
|
+
const FILTER_REMOVED_INTERACTION = "filter_removed";
|
|
1019
|
+
const FILTER_CHANGED_INTERACTION = "filter_changed";
|
|
1020
|
+
const FILTER_RESTORED_INTERACTION = "filter_restored";
|
|
1021
|
+
const VARIABLE_VALUE_CHANGED_INTERACTION = "variable_value_changed";
|
|
1022
|
+
const SCOPES_CHANGED_INTERACTION = "scopes_changed";
|
|
1023
|
+
|
|
1019
1024
|
class SceneTimeRange extends SceneObjectBase {
|
|
1020
1025
|
constructor(state = {}) {
|
|
1021
1026
|
var _a;
|
|
@@ -14596,6 +14601,7 @@ exports.SceneObjectUrlSyncConfig = SceneObjectUrlSyncConfig;
|
|
|
14596
14601
|
exports.SceneQueryRunner = SceneQueryRunner;
|
|
14597
14602
|
exports.SceneReactObject = SceneReactObject;
|
|
14598
14603
|
exports.SceneRefreshPicker = SceneRefreshPicker;
|
|
14604
|
+
exports.SceneRenderProfiler = SceneRenderProfiler;
|
|
14599
14605
|
exports.SceneTimePicker = SceneTimePicker;
|
|
14600
14606
|
exports.SceneTimeRange = SceneTimeRange;
|
|
14601
14607
|
exports.SceneTimeRangeCompare = SceneTimeRangeCompare;
|