blob: b89a25995ac4a05d3d514a66e37a1e5f2b75d9a7 (
plain)
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
|
"use strict";
(function() {
const { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm"
);
function startProfiler(settings) {
Services.profiler.StartProfiler(
settings.entries,
settings.interval,
settings.features,
settings.threads,
0,
settings.duration
);
info("Profiler has started");
}
function getProfile() {
const profile = Services.profiler.getProfileData();
info(
"We got a profile, run the mochitest with `--keep-open true` to see the logged profile in the Web Console."
);
// Run the mochitest with `--keep-open true` to see the logged profile in the
// Web console.
console.log(profile);
return profile;
}
function stopProfiler() {
Services.profiler.StopProfiler();
info("Profiler has stopped");
}
function end(error) {
if (error) {
ok(false, `We got an error: ${error}`);
} else {
ok(true, "We ran the whole process");
}
SimpleTest.finish();
}
async function runTest(settings, workload) {
SimpleTest.waitForExplicitFinish();
try {
await startProfiler(settings);
await workload();
await getProfile();
await stopProfiler();
await end();
} catch (e) {
// By catching and handling the error, we're being nice to mochitest
// runners: instead of waiting for the timeout, we fail right away.
await end(e);
}
}
window.runTest = runTest;
})();
|