MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / _print_index_stats

Method _print_index_stats

src/licensedcode/index.py:1153–1194  ·  view source on GitHub ↗

Print internal Index structures stats. Used for debugging and testing.

(self)

Source from the content-addressed store, hash-verified

1151 return matches
1152
1153 def _print_index_stats(self):
1154 """
1155 Print internal Index structures stats. Used for debugging and testing.
1156 """
1157 try:
1158 from pympler.asizeof import asizeof as size_of
1159 except ImportError:
1160 print('Index statistics will be approximate: `pip install pympler` '
1161 'for correct structure sizes')
1162 from sys import getsizeof as size_of
1163
1164 fields = (
1165 'dictionary',
1166 'tokens_by_tid',
1167 'rid_by_hash',
1168 'rules_by_rid',
1169 'tids_by_rid',
1170
1171 'sets_by_rid',
1172 'msets_by_rid',
1173
1174 'regular_rids',
1175 'approx_matchable_rids',
1176 'false_positive_rids',
1177 )
1178
1179 plen = max(map(len, fields)) + 1
1180 internal_structures = [s + (' ' * (plen - len(s))) for s in fields]
1181
1182 print('Index statistics:')
1183 total_size = 0
1184 for struct_name in internal_structures:
1185 struct = getattr(self, struct_name.strip())
1186 try:
1187 print(' ', struct_name, ':', 'length :', len(struct))
1188 except:
1189 print(' ', struct_name, ':', 'repr :', repr(struct))
1190 siz = size_of(struct)
1191 total_size += siz
1192 print(' ', struct_name, ':', 'size in MB:', round(siz / (1024 * 1024), 2))
1193 print(' TOTAL internals in MB:', round(total_size / (1024 * 1024), 2))
1194 print(' TOTAL real size in MB:', round(size_of(self) / (1024 * 1024), 2))
1195
1196 def _tokens2text(self, tokens):
1197 """

Callers 1

__init__Method · 0.95

Calls 2

mapFunction · 0.85
roundFunction · 0.85

Tested by

no test coverage detected