MCPcopy Create free account
hub / github.com/Snapchat/dagger-browser / ClassSizeService

Class ClassSizeService

browser/src/service/ClassSizeService.tsx:11–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 * Service to get class size for a given class name.
10 */
11export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected