Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1024095 // estimateWebBotSize [old version]

JavaX fragment (include)

1  
sclass SizeEstimate {
2  
  new Map<S, Long> shallowFieldSizes;
3  
  new Set<S> complexFields;
4  
  new Map<S, Long> complexFieldSizes;
5  
}
6  
7  
static SizeEstimate estimateWebBotSize(O o) {
8  
  new SizeEstimate se;
9  
  Collection<S> fields = fields(o);
10  
  for (S field : fields) {
11  
    if (sizeCalculation_shouldIgnoreProgramField(field)) continue;
12  
    O value = get(o, field);
13  
    if (value == null) continue;
14  
    Class type = value.getClass();
15  
    if (isBoxedType(type) || isPrimitiveArray(value))
16  
      continue with se.shallowFieldSizes.put(field, deepObjectSize(value));
17  
    se.complexFields.add(field);
18  
  }
19  
  
20  
  O[] array = asObjectArray(getFields(o, se.complexFields));
21  
  new guessDeepObjectSize_recursive_Data data;
22  
  data.seen.add(o);
23  
  ret guessDeepObjectSize_recursive(data, array)-inMemorySizeOfArray(array);
24  
}

Author comment

Began life as a copy of #1024089

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024095
Snippet name: estimateWebBotSize [old version]
Eternal ID of this version: #1024095/1
Text MD5: 85d29ff50673ed49d4a9de31c84eb04e
Author: stefan
Category: javax / html
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-20 18:29:58
Source code size: 824 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 181 / 212
Referenced in: [show references]