1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
// Copyright Epic Games, Inc. All Rights Reserved.
// Thin wrappers around the /api/* endpoints exposed by TraceViewerService.
const API = "api/";
const JSON_HEADERS = { Accept: "application/json" };
async function getJson(path) {
const response = await fetch(API + path, { headers: JSON_HEADERS });
if (!response.ok) {
throw new Error(`${path}: HTTP ${response.status}`);
}
return response.json();
}
export function getSession() {
return getJson("session");
}
export function getThreads() {
return getJson("threads");
}
export function getChannels() {
return getJson("channels");
}
export function getScopeStats() {
return getJson("scope-stats");
}
export function getScopeNames() {
return getJson("scope-names");
}
export async function getTimeline(threadId, startUs, endUs, minDurUs = 0, resolution = 0, { signal } = {}) {
const params = new URLSearchParams({
thread: String(threadId),
start: String(startUs),
end: String(endUs),
});
if (minDurUs > 0) params.set("mindur", String(minDurUs));
if (resolution > 0) params.set("resolution", String(resolution));
const response = await fetch(API + "timeline?" + params.toString(), { signal, headers: JSON_HEADERS });
if (!response.ok) {
throw new Error(`timeline: HTTP ${response.status}`);
}
return response.json();
}
export async function getTimelineBatch(threadIds, startUs, endUs, minDurUs = 0, resolution = 0, { signal } = {}) {
let url = `${API}timeline-batch?threads=${threadIds.join(",")}&start=${startUs}&end=${endUs}`;
if (minDurUs > 0) url += `&mindur=${minDurUs}`;
if (resolution > 0) url += `&resolution=${resolution}`;
const response = await fetch(url, { signal, headers: JSON_HEADERS });
if (!response.ok) {
throw new Error(`timeline-batch: HTTP ${response.status}`);
}
return response.json();
}
export function getLogCategories() {
return getJson("log-categories");
}
export function getLogs({ startUs = 0, endUs = 0xffffffff, minVerbosity = 0, category = null, limit = 5000 } = {}) {
const params = new URLSearchParams({
start: String(startUs),
end: String(endUs),
min_verbosity: String(minVerbosity),
limit: String(limit),
});
if (category !== null && category !== undefined) {
params.set("category", String(category));
}
return getJson("logs?" + params.toString());
}
export function getBookmarks() {
return getJson("bookmarks");
}
export function getRegions() {
return getJson("regions");
}
export function getCsvCategories() {
return getJson("csv-categories");
}
export function getCsvStats() {
return getJson("csv-stats");
}
export function getCsvSeries(statId, threadId) {
let url = "csv-series?";
if (statId != null) url += `stat=${statId}&`;
if (threadId != null) url += `thread=${threadId}&`;
return getJson(url);
}
export function getCsvEvents() {
return getJson("csv-events");
}
export function getCsvMetadata() {
return getJson("csv-metadata");
}
export function getCounters() {
return getJson("counters");
}
export function getCounterSeries(id) {
return getJson(`counter-series?id=${encodeURIComponent(id)}`);
}
export function getAllocSummary() {
return getJson("alloc-summary");
}
export function getMemoryTimeline({ startUs = 0, endUs = 0xffffffff, maxSamples = 2000 } = {}) {
const params = new URLSearchParams({
start: String(startUs),
end: String(endUs),
max_samples: String(maxSamples),
});
return getJson("memory-timeline?" + params.toString());
}
export function getCallstackStats(limit = 100) {
return getJson("callstack-stats?limit=" + encodeURIComponent(limit));
}
export function getChurnStats(limit = 100) {
return getJson("churn-stats?limit=" + encodeURIComponent(limit));
}
export function getCallstack(callstackId) {
return getJson("callstacks?id=" + encodeURIComponent(callstackId));
}
export function getAllocSizeHistogram() {
return getJson("alloc-size-histogram");
}
|