<commit_before>'''
Code related to memory and memory debugging
'''

import logging
import io
import resource
import gc

import objgraph

from . import config

LOGGER = logging.getLogger(__name__)

debugs = []


def register_debug(cref):
    '''
    Register a function to be called for a memory summary
    '''
    debugs.append(cref)


def _in_millions(m):
    return '{:.1f}mb'.format(m / 1000000.)


def print_summary():
    '''
    Log a summary of current memory usage
    '''<commit_msg>comment<commit_after>'''
Code related to memory and memory debugging
'''

import logging
import io
import resource
import gc

import objgraph

from . import config

LOGGER = logging.getLogger(__name__)

debugs = []


def register_debug(cref):
    '''
    Register a function to be called for a memory summary
    '''
    debugs.append(cref)


def _in_millions(m):
    return '{:.1f}mb'.format(m / 1000000.)


def print_summary():
    '''
    Log a summary of current memory usage. This is very expensive
    when there is a lot of memory used.
    '''
{'fraction_non_alphanumeric': 0.10153256704980843, 'fraction_numerical': 0.01532567049808429, 'mean_word_length': 3.3723849372384938, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '724019', 'n_tokens_mistral': 335, 'n_tokens_neox': 316, 'n_words': 114}