Total Complexity | 5 |
Complexity/F | 1 |
Lines of Code | 30 |
Function Count | 5 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { formatBytes } from '../utils/formatters'; |
||
2 | import Counter from './Counter'; |
||
3 | |||
4 | function safeGetKey(report, key) { |
||
5 | return report[key] || 0; |
||
6 | } |
||
7 | |||
8 | export default class ProcessMemoryCountrer extends Counter { |
||
9 | bench() { |
||
10 | return process.memoryUsage(); |
||
11 | } |
||
12 | |||
13 | static prettify(data) { |
||
14 | return formatBytes(data); |
||
15 | } |
||
16 | |||
17 | diff(start, end) { |
||
18 | const res = {}; |
||
19 | const keys = new Set([ |
||
20 | ...Object.keys(start), |
||
21 | ...Object.keys(end) |
||
22 | ]); |
||
23 | |||
24 | keys.forEach(key => { |
||
25 | res[key] = safeGetKey(end, key) - safeGetKey(start, key); |
||
26 | }); |
||
27 | |||
28 | return res; |
||
29 | } |
||
30 | } |
||
31 |