<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import Screen
import pygame, sys,os
from pygame.locals import *
import Mouse
import Reactor
from Render import initializeDisplay,calibrate,ConfKey
import Tuio
import Gestures
import pygame.display
import Agent

class MemSummary:
    def digest(self):
        import gc
        from Recognizer import Recognizer
        from collections import Counter
        counter = Counter(type(obj) for obj in gc.get_objects() if isinstance(obj, Recognizer))
        print "===========MEMORY=========="
        for t,c in counter.most_common():
            print t,":",c
            if c > 100: import pdb; pdb.set_trace()
        
        print
          
        print "%d Failed" % len([obj for obj in gc.get_objects() if isinstance(obj, Recognizer) and obj.failed])
        print "="*30
        Reactor.schedule_after(2,self,MemSummary.digest)<commit_msg>better debugging<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import Screen
import pygame, sys,os
from pygame.locals import *
import Mouse
import Reactor
from Render import initializeDisplay,calibrate,ConfKey
import Tuio
import Gestures
import pygame.display
import Agent

class MemSummary:
    def digest(self):
        import gc
        gc.collect()
        from Recognizer import Recognizer
        from collections import Counter
        counter = Counter(type(obj) for obj in gc.get_objects() if isinstance(obj, Recognizer))
        print "===========MEMORY=========="
        for t,c in counter.most_common():
            print t,":",c
            if c > 100: import pdb; pdb.set_trace()
        
        print
        lfailed = [obj for obj in gc.get_objects() if isinstance(obj, Recognizer) and obj.failed]
        print "%d Failed" % len(lfailed)
        print "="*30
        #import objgraph
        #objgraph.show_backrefs(lfailed, filename='failed.png')
        Reactor.schedule_after(2,self,MemSummary.digest)
        
{'fraction_non_alphanumeric': 0.11253196930946291, 'fraction_numerical': 0.007161125319693095, 'mean_word_length': 2.8128654970760234, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, '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': '6685846', 'n_tokens_mistral': 589, 'n_tokens_neox': 563, 'n_words': 171}