-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathplugins.js
More file actions
62 lines (54 loc) · 1.42 KB
/
plugins.js
File metadata and controls
62 lines (54 loc) · 1.42 KB
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
const {
V8OptimizeOnNextCallPlugin
} = require('./plugins/v8-opt');
const {
V8NeverOptimizePlugin
} = require('./plugins/v8-never-opt');
const {
V8GetOptimizationStatus,
} = require('./plugins/v8-print-status');
const {
MemoryPlugin,
} = require('./plugins/memory');
const {
RecordMemorySpikePlugin
} = require('./plugins/memory-spike');
const {
validateFunction,
validateArray,
} = require('./validators');
function validatePlugins(plugins) {
for (p of plugins) {
validateFunction(p.isSupported, 'Plugins must have a isSupported method.');
validateFunction(p.toString, 'Plugins must have a toString() method.');
if (!p.isSupported()) {
throw new Error(`Plugin: ${p.toString()} is not supported.`);
}
if (typeof p.beforeClockTemplate === 'function') {
const result = p.beforeClockTemplate({
bench: '',
awaitOrEmpty: '',
context: '',
timer: '',
});
validateArray(result, `${p.toString()}.beforeClockTemplate()`);
}
if (typeof p.afterClockTemplate === 'function') {
const result = p.afterClockTemplate({
bench: '',
awaitOrEmpty: '',
context: '',
timer: '',
});
validateArray(result, `${p.toString()}.afterClockTemplate()`);
}
}
}
module.exports = {
MemoryPlugin,
V8NeverOptimizePlugin,
V8GetOptimizationStatus,
V8OptimizeOnNextCallPlugin,
RecordMemorySpikePlugin,
validatePlugins,
};