| 9 | * Service to get class size for a given class name. |
| 10 | */ |
| 11 | export default class ClassSizeService implements WeightService { |
| 12 | /** Class information - method/field count and dex size - stored per fully qualified class name. */ |
| 13 | classInfo: { [key: string]: ClassInfo }; |
| 14 | |
| 15 | constructor(classInfo: { [key: string]: ClassInfo }) { |
| 16 | this.classInfo = classInfo; |
| 17 | } |
| 18 | |
| 19 | getWeight(componentName: string, node?: string): Weight | undefined { |
| 20 | const classSize = this.getClassSize(node ? node : componentName); |
| 21 | if (classSize) { |
| 22 | var memorySizeKb = classSize.getMemorySize() / 1024; |
| 23 | if (memorySizeKb > 1) { |
| 24 | memorySizeKb = Math.round(memorySizeKb); |
| 25 | } |
| 26 | |
| 27 | return { |
| 28 | value: memorySizeKb, |
| 29 | largeThreshold: LARGE_THRESHOLD_KB, |
| 30 | smallThreshold: SMALL_THRESHOLD_KB, |
| 31 | summary: classSize.getSummary(), |
| 32 | unit: 'kB' |
| 33 | } as Weight; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | getClassSize(className: string): ClassSize | undefined { |
| 38 | const info = this.classInfo[className]; |
| 39 | if (info) { |
| 40 | return new ClassSize(info); |
| 41 | } |
| 42 | } |
| 43 | } |
nothing calls this directly
no outgoing calls
no test coverage detected