@memlab/core 1.0.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/README.md +11 -0
- package/dist/__tests__/parser/HeapParser.test.d.ts +11 -0
- package/dist/__tests__/parser/HeapParser.test.d.ts.map +1 -0
- package/dist/__tests__/parser/HeapParser.test.js +54 -0
- package/dist/__tests__/parser/NodeHeap.test.d.ts +11 -0
- package/dist/__tests__/parser/NodeHeap.test.d.ts.map +1 -0
- package/dist/__tests__/parser/NodeHeap.test.js +96 -0
- package/dist/__tests__/parser/StringNode.test.d.ts +11 -0
- package/dist/__tests__/parser/StringNode.test.d.ts.map +1 -0
- package/dist/__tests__/parser/StringNode.test.js +61 -0
- package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts +16 -0
- package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.d.ts.map +1 -0
- package/dist/__tests__/parser/traverse/HeapNodeTraverse.test.js +140 -0
- package/dist/__tests__/utils/utils.test.d.ts +11 -0
- package/dist/__tests__/utils/utils.test.d.ts.map +1 -0
- package/dist/__tests__/utils/utils.test.js +81 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +62 -0
- package/dist/lib/BaseOption.d.ts +31 -0
- package/dist/lib/BaseOption.d.ts.map +1 -0
- package/dist/lib/BaseOption.js +109 -0
- package/dist/lib/BrowserInfo.d.ts +33 -0
- package/dist/lib/BrowserInfo.d.ts.map +1 -0
- package/dist/lib/BrowserInfo.js +117 -0
- package/dist/lib/Config.d.ts +203 -0
- package/dist/lib/Config.d.ts.map +1 -0
- package/dist/lib/Config.js +427 -0
- package/dist/lib/Console.d.ts +67 -0
- package/dist/lib/Console.d.ts.map +1 -0
- package/dist/lib/Console.js +344 -0
- package/dist/lib/Constant.d.ts +38 -0
- package/dist/lib/Constant.d.ts.map +1 -0
- package/dist/lib/Constant.js +58 -0
- package/dist/lib/FileManager.d.ts +69 -0
- package/dist/lib/FileManager.d.ts.map +1 -0
- package/dist/lib/FileManager.js +309 -0
- package/dist/lib/HeapAnalyzer.d.ts +51 -0
- package/dist/lib/HeapAnalyzer.d.ts.map +1 -0
- package/dist/lib/HeapAnalyzer.js +719 -0
- package/dist/lib/HeapParser.d.ts +19 -0
- package/dist/lib/HeapParser.d.ts.map +1 -0
- package/dist/lib/HeapParser.js +128 -0
- package/dist/lib/InternalValueSetter.d.ts +14 -0
- package/dist/lib/InternalValueSetter.d.ts.map +1 -0
- package/dist/lib/InternalValueSetter.js +43 -0
- package/dist/lib/NodeHeap.d.ts +16 -0
- package/dist/lib/NodeHeap.d.ts.map +1 -0
- package/dist/lib/NodeHeap.js +62 -0
- package/dist/lib/ProcessManager.d.ts +25 -0
- package/dist/lib/ProcessManager.d.ts.map +1 -0
- package/dist/lib/ProcessManager.js +67 -0
- package/dist/lib/Serializer.d.ts +49 -0
- package/dist/lib/Serializer.d.ts.map +1 -0
- package/dist/lib/Serializer.js +702 -0
- package/dist/lib/StringLoader.d.ts +26 -0
- package/dist/lib/StringLoader.d.ts.map +1 -0
- package/dist/lib/StringLoader.js +290 -0
- package/dist/lib/Types.d.ts +432 -0
- package/dist/lib/Types.d.ts.map +1 -0
- package/dist/lib/Types.js +11 -0
- package/dist/lib/Utils.d.ts +223 -0
- package/dist/lib/Utils.d.ts.map +1 -0
- package/dist/lib/Utils.js +1736 -0
- package/dist/lib/heap-data/HeapEdge.d.ts +27 -0
- package/dist/lib/heap-data/HeapEdge.d.ts.map +1 -0
- package/dist/lib/heap-data/HeapEdge.js +75 -0
- package/dist/lib/heap-data/HeapLocation.d.ts +22 -0
- package/dist/lib/heap-data/HeapLocation.d.ts.map +1 -0
- package/dist/lib/heap-data/HeapLocation.js +40 -0
- package/dist/lib/heap-data/HeapNode.d.ts +55 -0
- package/dist/lib/heap-data/HeapNode.d.ts.map +1 -0
- package/dist/lib/heap-data/HeapNode.js +344 -0
- package/dist/lib/heap-data/HeapSnapshot.d.ts +85 -0
- package/dist/lib/heap-data/HeapSnapshot.d.ts.map +1 -0
- package/dist/lib/heap-data/HeapSnapshot.js +462 -0
- package/dist/lib/heap-data/HeapStringNode.d.ts +18 -0
- package/dist/lib/heap-data/HeapStringNode.d.ts.map +1 -0
- package/dist/lib/heap-data/HeapStringNode.js +43 -0
- package/dist/lib/heap-data/HeapUtils.d.ts +17 -0
- package/dist/lib/heap-data/HeapUtils.d.ts.map +1 -0
- package/dist/lib/heap-data/HeapUtils.js +25 -0
- package/dist/logger/LeakClusterLogger.d.ts +40 -0
- package/dist/logger/LeakClusterLogger.d.ts.map +1 -0
- package/dist/logger/LeakClusterLogger.js +228 -0
- package/dist/logger/LeakTraceDetailsLogger.d.ts +19 -0
- package/dist/logger/LeakTraceDetailsLogger.d.ts.map +1 -0
- package/dist/logger/LeakTraceDetailsLogger.js +50 -0
- package/dist/modes/BaseMode.d.ts +30 -0
- package/dist/modes/BaseMode.d.ts.map +1 -0
- package/dist/modes/BaseMode.js +95 -0
- package/dist/modes/InteractionTestMode.d.ts +23 -0
- package/dist/modes/InteractionTestMode.d.ts.map +1 -0
- package/dist/modes/InteractionTestMode.js +46 -0
- package/dist/modes/MeasureMode.d.ts +23 -0
- package/dist/modes/MeasureMode.d.ts.map +1 -0
- package/dist/modes/MeasureMode.js +58 -0
- package/dist/modes/RunningModes.d.ts +15 -0
- package/dist/modes/RunningModes.d.ts.map +1 -0
- package/dist/modes/RunningModes.js +40 -0
- package/dist/paths/TraceFinder.d.ts +31 -0
- package/dist/paths/TraceFinder.d.ts.map +1 -0
- package/dist/paths/TraceFinder.js +537 -0
- package/dist/trace-cluster/ClusterUtils.d.ts +14 -0
- package/dist/trace-cluster/ClusterUtils.d.ts.map +1 -0
- package/dist/trace-cluster/ClusterUtils.js +17 -0
- package/dist/trace-cluster/ClusterUtilsHelper.d.ts +38 -0
- package/dist/trace-cluster/ClusterUtilsHelper.d.ts.map +1 -0
- package/dist/trace-cluster/ClusterUtilsHelper.js +373 -0
- package/dist/trace-cluster/ClusteringHeuristics.d.ts +22 -0
- package/dist/trace-cluster/ClusteringHeuristics.d.ts.map +1 -0
- package/dist/trace-cluster/ClusteringHeuristics.js +23 -0
- package/dist/trace-cluster/EvalutationMetric.d.ts +22 -0
- package/dist/trace-cluster/EvalutationMetric.d.ts.map +1 -0
- package/dist/trace-cluster/EvalutationMetric.js +158 -0
- package/dist/trace-cluster/TraceBucket.d.ts +36 -0
- package/dist/trace-cluster/TraceBucket.d.ts.map +1 -0
- package/dist/trace-cluster/TraceBucket.js +238 -0
- package/dist/trace-cluster/TraceElement.d.ts +71 -0
- package/dist/trace-cluster/TraceElement.d.ts.map +1 -0
- package/dist/trace-cluster/TraceElement.js +182 -0
- package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts +15 -0
- package/dist/trace-cluster/strategies/TraceAsClusterStrategy.d.ts.map +1 -0
- package/dist/trace-cluster/strategies/TraceAsClusterStrategy.js +37 -0
- package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts +15 -0
- package/dist/trace-cluster/strategies/TraceSimilarityStrategy.d.ts.map +1 -0
- package/dist/trace-cluster/strategies/TraceSimilarityStrategy.js +60 -0
- package/package.json +60 -0
- package/static/run-meta.json +10 -0
- package/static/visit-order.json +27 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @emails oncall+ws_labs
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
const BrowserInfo_1 = __importDefault(require("../lib/BrowserInfo"));
|
|
25
|
+
const Config_1 = __importDefault(require("../lib/Config"));
|
|
26
|
+
const Console_1 = __importDefault(require("../lib/Console"));
|
|
27
|
+
const Serializer_1 = __importDefault(require("../lib/Serializer"));
|
|
28
|
+
const Utils_1 = __importDefault(require("../lib/Utils"));
|
|
29
|
+
const TraceBucket_1 = __importDefault(require("../trace-cluster/TraceBucket"));
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const util_1 = require("util");
|
|
33
|
+
const readdir = (0, util_1.promisify)(fs_1.default.readdir);
|
|
34
|
+
const readFile = (0, util_1.promisify)(fs_1.default.readFile);
|
|
35
|
+
class LeakClusterLogger {
|
|
36
|
+
constructor() {
|
|
37
|
+
this._fileIdx = 0;
|
|
38
|
+
}
|
|
39
|
+
_loadClustersData(dir) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const files = yield readdir(dir);
|
|
42
|
+
return Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const p = path_1.default.join(dir, file);
|
|
44
|
+
const content = yield readFile(p, 'UTF-8');
|
|
45
|
+
return JSON.parse(content);
|
|
46
|
+
})));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
loadClusters(dir) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const data = yield this._loadClustersData(dir);
|
|
52
|
+
return data.map((info) => {
|
|
53
|
+
const meta = JSON.parse(info.meta_data);
|
|
54
|
+
const traceRecord = meta.trace_record;
|
|
55
|
+
return {
|
|
56
|
+
id: info.cluster_id,
|
|
57
|
+
path: TraceBucket_1.default.traceToPath(traceRecord),
|
|
58
|
+
clusterMetaInfo: info,
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
dumpReadableCluster(options = {}) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const metaFile = options.metaFile;
|
|
66
|
+
if (!metaFile || !fs_1.default.existsSync(metaFile)) {
|
|
67
|
+
throw Utils_1.default.haltOrThrow(`File doesn't exist: ${metaFile}`);
|
|
68
|
+
}
|
|
69
|
+
const meta = yield this.loadClusterMeta(metaFile);
|
|
70
|
+
Console_1.default.topLevel(`\nApp: ${meta.app}, Interaction: ${meta.interaction}`);
|
|
71
|
+
Console_1.default.lowLevel(`Created on: ${new Date(meta.creation_time * 1000)}`);
|
|
72
|
+
Console_1.default.topLevel(`\nTest interactions: ${meta.interaction_summary}`);
|
|
73
|
+
Console_1.default.topLevel(`\nLeak trace:`);
|
|
74
|
+
Console_1.default.topLevel(meta.leak_trace_summary);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
loadClusterMeta(file) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const content = yield readFile(file, 'UTF-8');
|
|
80
|
+
return JSON.parse(content);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
logUnclassifiedClusters(clusters) {
|
|
84
|
+
const tabsOrder = Utils_1.default.loadTabsOrder();
|
|
85
|
+
const interactSummary = Serializer_1.default.summarizeTabsOrder(tabsOrder);
|
|
86
|
+
const interactionVector = tabsOrder.map(tab => tab.name);
|
|
87
|
+
for (const cluster of clusters) {
|
|
88
|
+
this._logSingleUnClassifiedCluster(tabsOrder, cluster, interactSummary, interactionVector);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
logClusters(clusters, options = {}) {
|
|
92
|
+
this._saveClusterSummary(clusters);
|
|
93
|
+
if (Config_1.default.useExternalSnapshot) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const tabsOrder = Utils_1.default.loadTabsOrder();
|
|
97
|
+
const interactSummary = Serializer_1.default.summarizeTabsOrder(tabsOrder);
|
|
98
|
+
const interactionVector = tabsOrder.map(tab => tab.name);
|
|
99
|
+
for (const cluster of clusters) {
|
|
100
|
+
this._logCluster(tabsOrder, cluster, interactSummary, interactionVector);
|
|
101
|
+
}
|
|
102
|
+
// manage unique clusters
|
|
103
|
+
if (!options.clusterDiff) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.logClusterDiff(options.clusterDiff);
|
|
107
|
+
}
|
|
108
|
+
logAllClusters(clusters) {
|
|
109
|
+
const file = Config_1.default.allClusterSummaryFile;
|
|
110
|
+
let content = '';
|
|
111
|
+
for (let i = 0; i < clusters.length; ++i) {
|
|
112
|
+
content += `--------- cluster ${i + 1} ---------\n\n`;
|
|
113
|
+
for (let j = 0; j < clusters[i].length; ++j) {
|
|
114
|
+
const cluster = clusters[i][j];
|
|
115
|
+
content += `cluster: ${cluster.id}\n\n`;
|
|
116
|
+
let traceSummary;
|
|
117
|
+
if (cluster.clusterMetaInfo) {
|
|
118
|
+
traceSummary = cluster.clusterMetaInfo.leak_trace_summary;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const trace = new TraceBucket_1.default(cluster.path, cluster.snapshot);
|
|
122
|
+
traceSummary = trace.getTraceSummary();
|
|
123
|
+
}
|
|
124
|
+
content += traceSummary + '\n\n';
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
fs_1.default.writeFileSync(file, content, 'UTF-8');
|
|
128
|
+
}
|
|
129
|
+
logClusterDiff(clusterDiff) {
|
|
130
|
+
const staleClusters = clusterDiff.staleClusters || [];
|
|
131
|
+
for (const cluster of staleClusters) {
|
|
132
|
+
this._logStaleCluster(cluster);
|
|
133
|
+
}
|
|
134
|
+
const clustersToAdd = clusterDiff.clustersToAdd || [];
|
|
135
|
+
for (const cluster of clustersToAdd) {
|
|
136
|
+
this._logClusterToAdd(cluster);
|
|
137
|
+
}
|
|
138
|
+
this.logAllClusters(clusterDiff.allClusters);
|
|
139
|
+
}
|
|
140
|
+
_logStaleCluster(cluster) {
|
|
141
|
+
const info = {
|
|
142
|
+
cluster_id: cluster.id,
|
|
143
|
+
};
|
|
144
|
+
const file = path_1.default.join(Config_1.default.staleUniqueClusterDir, `cluster-${cluster.id}.json`);
|
|
145
|
+
fs_1.default.writeFileSync(file, JSON.stringify(info, null, 2), 'UTF-8');
|
|
146
|
+
}
|
|
147
|
+
_logClusterToAdd(cluster) {
|
|
148
|
+
const tabsOrder = Utils_1.default.loadTabsOrder();
|
|
149
|
+
const interactSummary = Serializer_1.default.summarizeTabsOrder(tabsOrder);
|
|
150
|
+
const interactionVector = tabsOrder.map(tab => tab.name);
|
|
151
|
+
const nodeId = Utils_1.default.getLastNodeId(cluster.path);
|
|
152
|
+
const filepath = path_1.default.join(Config_1.default.newUniqueClusterDir, `@${nodeId}.json`);
|
|
153
|
+
this._logCluster(tabsOrder, cluster, interactSummary, interactionVector, {
|
|
154
|
+
filepath,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
_saveClusterSummary(clusters) {
|
|
158
|
+
// log cluster summary to a readable file
|
|
159
|
+
fs_1.default.appendFileSync(Config_1.default.exploreResultFile, `\n------${clusters.length} clusters------\n`, 'UTF-8');
|
|
160
|
+
const opt = { color: !Config_1.default.isContinuousTest };
|
|
161
|
+
for (const cluster of clusters) {
|
|
162
|
+
const size = Utils_1.default.getReadableBytes(cluster.retainedSize);
|
|
163
|
+
const stat = `\n--Similar leaks in this run: ${cluster.count}--` +
|
|
164
|
+
`\n--Retained size of leaked objects: ${size}--\n`;
|
|
165
|
+
const { path, snapshot } = cluster;
|
|
166
|
+
if (snapshot) {
|
|
167
|
+
// print trace in terminal
|
|
168
|
+
let trace = Serializer_1.default.summarizePath(path, new Set(), snapshot, opt);
|
|
169
|
+
Console_1.default.topLevel(stat + trace);
|
|
170
|
+
// dump plain text train in files
|
|
171
|
+
trace = Serializer_1.default.summarizePath(path, new Set(), snapshot);
|
|
172
|
+
fs_1.default.appendFileSync(Config_1.default.exploreResultFile, stat + trace, 'UTF-8');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
_logCluster(tabsOrder, cluster, interactSummary, interactionVector, options = {}) {
|
|
177
|
+
const file = options.filepath || this._getTraceFilePath(cluster);
|
|
178
|
+
const trace = new TraceBucket_1.default(cluster.path, cluster.snapshot);
|
|
179
|
+
const info = {
|
|
180
|
+
cluster_id: cluster.id || 0,
|
|
181
|
+
creation_time: Date.now(),
|
|
182
|
+
app: Config_1.default.targetApp,
|
|
183
|
+
interaction: Config_1.default.targetTab,
|
|
184
|
+
num_duplicates: cluster.count,
|
|
185
|
+
retained_size: cluster.retainedSize,
|
|
186
|
+
interaction_summary: interactSummary,
|
|
187
|
+
leak_trace_summary: trace.getTraceSummary(),
|
|
188
|
+
interaction_vector: interactionVector,
|
|
189
|
+
meta_data: JSON.stringify({
|
|
190
|
+
browser_info: BrowserInfo_1.default,
|
|
191
|
+
visit_plan: tabsOrder,
|
|
192
|
+
trace_record: TraceBucket_1.default.pathToTrace(cluster.path),
|
|
193
|
+
}),
|
|
194
|
+
};
|
|
195
|
+
fs_1.default.writeFileSync(file, JSON.stringify(info, null, 2), 'UTF-8');
|
|
196
|
+
}
|
|
197
|
+
_getTraceFilePath(cluster) {
|
|
198
|
+
const filename = `@${Utils_1.default.getLastNodeId(cluster.path)}.json`;
|
|
199
|
+
return path_1.default.join(Config_1.default.traceClusterOutDir, filename);
|
|
200
|
+
}
|
|
201
|
+
_logSingleUnClassifiedCluster(tabsOrder, cluster, interactSummary, interactionVector, options = {}) {
|
|
202
|
+
var _a;
|
|
203
|
+
const file = options.filepath || this._getUnclassifiedTraceFilePath(cluster);
|
|
204
|
+
const trace = new TraceBucket_1.default(cluster.path, cluster.snapshot);
|
|
205
|
+
const info = {
|
|
206
|
+
cluster_id: (_a = cluster.id) !== null && _a !== void 0 ? _a : 0,
|
|
207
|
+
creation_time: Date.now(),
|
|
208
|
+
app: Config_1.default.targetApp,
|
|
209
|
+
interaction: Config_1.default.targetTab,
|
|
210
|
+
num_duplicates: cluster.count,
|
|
211
|
+
retained_size: cluster.retainedSize,
|
|
212
|
+
interaction_summary: interactSummary,
|
|
213
|
+
leak_trace_summary: trace.getTraceSummary(),
|
|
214
|
+
interaction_vector: interactionVector,
|
|
215
|
+
meta_data: JSON.stringify({
|
|
216
|
+
browser_info: BrowserInfo_1.default,
|
|
217
|
+
visit_plan: tabsOrder,
|
|
218
|
+
trace_record: TraceBucket_1.default.pathToTrace(cluster.path),
|
|
219
|
+
}),
|
|
220
|
+
};
|
|
221
|
+
fs_1.default.writeFileSync(file, JSON.stringify(info, null, 2), 'UTF-8');
|
|
222
|
+
}
|
|
223
|
+
_getUnclassifiedTraceFilePath(cluster) {
|
|
224
|
+
const filename = `@${Utils_1.default.getLastNodeId(cluster.path)}.json`;
|
|
225
|
+
return path_1.default.join(Config_1.default.unclassifiedClusterDir, filename);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.default = new LeakClusterLogger();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+ws_labs
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
import { IHeapSnapshot, LeakTracePathItem } from '../lib/Types';
|
|
11
|
+
declare class LeakTraceDetailsLogger {
|
|
12
|
+
_wrapPathJSONInLoader(jsonContent: string): string;
|
|
13
|
+
setTraceFileEmpty(filepath: string): void;
|
|
14
|
+
logTrace(leakedIdSet: Set<number>, snapshot: IHeapSnapshot, nodeIdsInSnapshots: Array<Set<number>>, trace: LeakTracePathItem, filepath: string): void;
|
|
15
|
+
logTraces(leakedIdSet: Set<number>, snapshot: IHeapSnapshot, nodeIdsInSnapshots: Array<Set<number>>, traces: LeakTracePathItem[], outDir: string): void;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: LeakTraceDetailsLogger;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=LeakTraceDetailsLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LeakTraceDetailsLogger.d.ts","sourceRoot":"","sources":["../../src/logger/LeakTraceDetailsLogger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EAAC,aAAa,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAE9D,cAAM,sBAAsB;IAC1B,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM;IAIlD,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOzC,QAAQ,CACN,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,QAAQ,EAAE,aAAa,EACvB,kBAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EACtC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,GACf,IAAI;IAUP,SAAS,CACP,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,QAAQ,EAAE,aAAa,EACvB,kBAAkB,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EACtC,MAAM,EAAE,iBAAiB,EAAE,EAC3B,MAAM,EAAE,MAAM,GACb,IAAI;CAUR;;AAED,wBAA4C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @emails oncall+ws_labs
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const Config_1 = __importDefault(require("../lib/Config"));
|
|
16
|
+
const Serializer_1 = __importDefault(require("../lib/Serializer"));
|
|
17
|
+
const Utils_1 = __importDefault(require("../lib/Utils"));
|
|
18
|
+
const fs_1 = __importDefault(require("fs"));
|
|
19
|
+
const path_1 = __importDefault(require("path"));
|
|
20
|
+
class LeakTraceDetailsLogger {
|
|
21
|
+
_wrapPathJSONInLoader(jsonContent) {
|
|
22
|
+
return `window.gcPath = ${jsonContent};`;
|
|
23
|
+
}
|
|
24
|
+
setTraceFileEmpty(filepath) {
|
|
25
|
+
const content = this._wrapPathJSONInLoader('');
|
|
26
|
+
fs_1.default.writeFile(filepath, content, 'UTF-8', () => {
|
|
27
|
+
// noop
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
logTrace(leakedIdSet, snapshot, nodeIdsInSnapshots, trace, filepath) {
|
|
31
|
+
const options = { leakedIdSet, nodeIdsInSnapshots };
|
|
32
|
+
const gcTrace = Serializer_1.default.JSONifyPath(trace, snapshot, options);
|
|
33
|
+
const traceJSON = JSON.stringify(gcTrace, null, 2);
|
|
34
|
+
const content = this._wrapPathJSONInLoader(traceJSON);
|
|
35
|
+
fs_1.default.writeFile(filepath, content, 'UTF-8', () => {
|
|
36
|
+
// noop
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
logTraces(leakedIdSet, snapshot, nodeIdsInSnapshots, traces, outDir) {
|
|
40
|
+
if (!Config_1.default.isContinuousTest) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
for (const trace of traces) {
|
|
44
|
+
const nodeId = Utils_1.default.getLastNodeId(trace);
|
|
45
|
+
const file = path_1.default.join(outDir, `@${nodeId}.json`);
|
|
46
|
+
this.logTrace(leakedIdSet, snapshot, nodeIdsInSnapshots, trace, file);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = new LeakTraceDetailsLogger();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+ws_labs
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
import type { E2EStepInfo, Config, IE2EScenarioVisitPlan, Optional } from '../lib/Types';
|
|
11
|
+
import type { Page } from 'puppeteer';
|
|
12
|
+
declare class BaseMode {
|
|
13
|
+
protected config: Config;
|
|
14
|
+
protected visitPlan: Optional<IE2EScenarioVisitPlan>;
|
|
15
|
+
setConfig(config: Config): void;
|
|
16
|
+
beforeRunning(visitPlan: IE2EScenarioVisitPlan): void;
|
|
17
|
+
shouldGC(_tabInfo?: E2EStepInfo): boolean;
|
|
18
|
+
shouldScroll(_tabInfo?: E2EStepInfo): boolean;
|
|
19
|
+
shouldGetMetrics(_tabInfo?: E2EStepInfo): boolean;
|
|
20
|
+
shouldUseConciseConsole(_tabInfo?: E2EStepInfo): boolean;
|
|
21
|
+
shouldTakeScreenShot(_tabInfo?: E2EStepInfo): boolean;
|
|
22
|
+
shouldTakeHeapSnapshot(_tabInfo?: E2EStepInfo): boolean;
|
|
23
|
+
shouldExtraWaitForTarget(_tabInfo?: E2EStepInfo): boolean;
|
|
24
|
+
shouldExtraWaitForFinal(_tabInfo?: E2EStepInfo): boolean;
|
|
25
|
+
shouldRunExtraTargetOperations(_tabInfo?: E2EStepInfo): boolean;
|
|
26
|
+
getAdditionalMetrics(_page: Page, _tabInfo?: E2EStepInfo): Promise<E2EStepInfo['metrics']>;
|
|
27
|
+
postProcessData(_visitPlan: IE2EScenarioVisitPlan): void;
|
|
28
|
+
}
|
|
29
|
+
export default BaseMode;
|
|
30
|
+
//# sourceMappingURL=BaseMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseMode.d.ts","sourceRoot":"","sources":["../../src/modes/BaseMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,MAAM,EACN,qBAAqB,EACrB,QAAQ,EACT,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAIpC,cAAM,QAAQ;IACZ,SAAS,CAAC,MAAM,EAAE,MAAM,CAAiB;IACzC,SAAS,CAAC,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACrD,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,aAAa,CAAC,SAAS,EAAE,qBAAqB,GAAG,IAAI;IAKrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAKzC,YAAY,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAK7C,gBAAgB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAKjD,uBAAuB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAKxD,oBAAoB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAKrD,sBAAsB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAKvD,wBAAwB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAQzD,uBAAuB,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAQxD,8BAA8B,CAAC,QAAQ,CAAC,EAAE,WAAW,GAAG,OAAO;IAOzD,oBAAoB,CAExB,KAAK,EAAE,IAAI,EAEX,QAAQ,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAKlC,eAAe,CAAC,UAAU,EAAE,qBAAqB,GAAG,IAAI;CAGzD;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @emails oncall+ws_labs
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
const Config_1 = __importDefault(require("../lib/Config"));
|
|
25
|
+
// the regular mode for conventional MemLab runs
|
|
26
|
+
class BaseMode {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.config = Config_1.default;
|
|
29
|
+
}
|
|
30
|
+
setConfig(config) {
|
|
31
|
+
this.config = config;
|
|
32
|
+
}
|
|
33
|
+
beforeRunning(visitPlan) {
|
|
34
|
+
this.visitPlan = visitPlan;
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
+
shouldGC(_tabInfo) {
|
|
38
|
+
return !this.config.skipGC;
|
|
39
|
+
}
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
+
shouldScroll(_tabInfo) {
|
|
42
|
+
return !this.config.skipScroll;
|
|
43
|
+
}
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
|
+
shouldGetMetrics(_tabInfo) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
|
+
shouldUseConciseConsole(_tabInfo) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
|
+
shouldTakeScreenShot(_tabInfo) {
|
|
54
|
+
return !this.config.skipScreenshot;
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
57
|
+
shouldTakeHeapSnapshot(_tabInfo) {
|
|
58
|
+
return !this.config.skipSnapshot;
|
|
59
|
+
}
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
61
|
+
shouldExtraWaitForTarget(_tabInfo) {
|
|
62
|
+
if (this.visitPlan && this.visitPlan.type === 'repeat') {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return !this.config.skipExtraOps;
|
|
66
|
+
}
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
68
|
+
shouldExtraWaitForFinal(_tabInfo) {
|
|
69
|
+
if (this.visitPlan && this.visitPlan.type === 'repeat') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return !this.config.skipExtraOps;
|
|
73
|
+
}
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
75
|
+
shouldRunExtraTargetOperations(_tabInfo) {
|
|
76
|
+
if (this.visitPlan && this.visitPlan.type === 'repeat') {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return !this.config.skipExtraOps;
|
|
80
|
+
}
|
|
81
|
+
getAdditionalMetrics(
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
|
+
_page,
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
|
+
_tabInfo) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
return {};
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
+
postProcessData(_visitPlan) {
|
|
92
|
+
// for overriding
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.default = BaseMode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+ws_labs
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
import BaseMode from './BaseMode';
|
|
11
|
+
declare class InteractionTestMode extends BaseMode {
|
|
12
|
+
shouldGC(): boolean;
|
|
13
|
+
shouldScroll(): boolean;
|
|
14
|
+
shouldGetMetrics(): boolean;
|
|
15
|
+
shouldUseConciseConsole(): boolean;
|
|
16
|
+
shouldTakeScreenShot(): boolean;
|
|
17
|
+
shouldTakeHeapSnapshot(): boolean;
|
|
18
|
+
shouldExtraWaitForTarget(): boolean;
|
|
19
|
+
shouldExtraWaitForFinal(): boolean;
|
|
20
|
+
shouldRunExtraTargetOperations(): boolean;
|
|
21
|
+
}
|
|
22
|
+
export default InteractionTestMode;
|
|
23
|
+
//# sourceMappingURL=InteractionTestMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InteractionTestMode.d.ts","sourceRoot":"","sources":["../../src/modes/InteractionTestMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,QAAQ,MAAM,YAAY,CAAC;AAGlC,cAAM,mBAAoB,SAAQ,QAAQ;IACxC,QAAQ,IAAI,OAAO;IAInB,YAAY,IAAI,OAAO;IAIvB,gBAAgB,IAAI,OAAO;IAI3B,uBAAuB,IAAI,OAAO;IAIlC,oBAAoB,IAAI,OAAO;IAI/B,sBAAsB,IAAI,OAAO;IAIjC,wBAAwB,IAAI,OAAO;IAInC,uBAAuB,IAAI,OAAO;IAIlC,8BAA8B,IAAI,OAAO;CAG1C;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @emails oncall+ws_labs
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const BaseMode_1 = __importDefault(require("./BaseMode"));
|
|
16
|
+
// mode for running quick interaction test
|
|
17
|
+
class InteractionTestMode extends BaseMode_1.default {
|
|
18
|
+
shouldGC() {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
shouldScroll() {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
shouldGetMetrics() {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
shouldUseConciseConsole() {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
shouldTakeScreenShot() {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
shouldTakeHeapSnapshot() {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
shouldExtraWaitForTarget() {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
shouldExtraWaitForFinal() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
shouldRunExtraTargetOperations() {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = InteractionTestMode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+ws_labs
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
import BaseMode from './BaseMode';
|
|
11
|
+
import type { Page } from 'puppeteer';
|
|
12
|
+
import type { E2EStepInfo, IE2EScenarioVisitPlan } from '../lib/Types';
|
|
13
|
+
declare class MeasureMode extends BaseMode {
|
|
14
|
+
shouldTakeScreenShot(): boolean;
|
|
15
|
+
shouldTakeHeapSnapshot(): boolean;
|
|
16
|
+
shouldExtraWaitForTarget(): boolean;
|
|
17
|
+
shouldExtraWaitForFinal(): boolean;
|
|
18
|
+
shouldRunExtraTargetOperations(): boolean;
|
|
19
|
+
getAdditionalMetrics(page: Page): Promise<E2EStepInfo['metrics']>;
|
|
20
|
+
postProcessData(visitPlan: IE2EScenarioVisitPlan): void;
|
|
21
|
+
}
|
|
22
|
+
export default MeasureMode;
|
|
23
|
+
//# sourceMappingURL=MeasureMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MeasureMode.d.ts","sourceRoot":"","sources":["../../src/modes/MeasureMode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,QAAQ,MAAM,YAAY,CAAC;AAIlC,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,EAAC,WAAW,EAAE,qBAAqB,EAAC,MAAM,cAAc,CAAC;AAGrE,cAAM,WAAY,SAAQ,QAAQ;IAChC,oBAAoB,IAAI,OAAO;IAI/B,sBAAsB,IAAI,OAAO;IAIjC,wBAAwB,IAAI,OAAO;IAInC,uBAAuB,IAAI,OAAO;IAIlC,8BAA8B,IAAI,OAAO;IAInC,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAQvE,eAAe,CAAC,SAAS,EAAE,qBAAqB,GAAG,IAAI;CAMxD;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @emails oncall+ws_labs
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
const BaseMode_1 = __importDefault(require("./BaseMode"));
|
|
25
|
+
const fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const path_1 = __importDefault(require("path"));
|
|
27
|
+
// mode for running quick measurement or experiments
|
|
28
|
+
class MeasureMode extends BaseMode_1.default {
|
|
29
|
+
shouldTakeScreenShot() {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
shouldTakeHeapSnapshot() {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
shouldExtraWaitForTarget() {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
shouldExtraWaitForFinal() {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
shouldRunExtraTargetOperations() {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
getAdditionalMetrics(page) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
// number of DOM elements on the page
|
|
47
|
+
const numDOMElements = yield page.evaluate(() => document.getElementsByTagName('*').length);
|
|
48
|
+
return { numDOMElements };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
postProcessData(visitPlan) {
|
|
52
|
+
const filename = `metrics-${Date.now()}-${process.pid}.json`;
|
|
53
|
+
const filepath = path_1.default.join(this.config.metricsOutDir, filename);
|
|
54
|
+
const content = JSON.stringify(visitPlan.tabsOrder, null, 2);
|
|
55
|
+
fs_1.default.writeFileSync(filepath, content, 'UTF-8');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = MeasureMode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @emails oncall+ws_labs
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
import type { Config, IRunningMode } from '../lib/Types';
|
|
11
|
+
declare const _default: {
|
|
12
|
+
get(name: string, config?: Config): IRunningMode;
|
|
13
|
+
};
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=RunningModes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RunningModes.d.ts","sourceRoot":"","sources":["../../src/modes/RunningModes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAC,MAAM,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;;cAQ3C,MAAM,WAAW,MAAM,GAAG,YAAY;;AADlD,wBAqBE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
* @emails oncall+ws_labs
|
|
9
|
+
* @format
|
|
10
|
+
*/
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const Utils_1 = __importDefault(require("../lib/Utils"));
|
|
16
|
+
const BaseMode_1 = __importDefault(require("./BaseMode"));
|
|
17
|
+
const InteractionTestMode_1 = __importDefault(require("./InteractionTestMode"));
|
|
18
|
+
const MeasureMode_1 = __importDefault(require("./MeasureMode"));
|
|
19
|
+
exports.default = {
|
|
20
|
+
get(name, config) {
|
|
21
|
+
let ret;
|
|
22
|
+
switch (name) {
|
|
23
|
+
case 'regular':
|
|
24
|
+
ret = new BaseMode_1.default();
|
|
25
|
+
break;
|
|
26
|
+
case 'interaction-test':
|
|
27
|
+
ret = new InteractionTestMode_1.default();
|
|
28
|
+
break;
|
|
29
|
+
case 'measure':
|
|
30
|
+
ret = new MeasureMode_1.default();
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
throw Utils_1.default.haltOrThrow(`unknown running mode: ${name}`);
|
|
34
|
+
}
|
|
35
|
+
if (config) {
|
|
36
|
+
ret.setConfig(config);
|
|
37
|
+
}
|
|
38
|
+
return ret;
|
|
39
|
+
},
|
|
40
|
+
};
|