Exemple #1
0
 def _print_functions(self,
                      obj,
                      name=None,
                      align=8,
                      detail=MAX,
                      code=False,
                      limit=MAX,
                      opt='',
                      **unused):
     if name:
         self._printf('%sasizeof functions for %s ... %s', os.linesep, name,
                      opt)
     self._printf('%s(): %s', ' basicsize', asizeof.basicsize(obj))
     self._printf('%s(): %s', ' itemsize', asizeof.itemsize(obj))
     self._printf('%s(): %r', ' leng', asizeof.leng(obj))
     self._printf('%s(): %s', ' refs', _repr(asizeof.refs(obj)))
     self._printf('%s(): %s', ' flatsize',
                  asizeof.flatsize(obj, align=align))  # , code=code
     self._printf(
         '%s(): %s', ' asized',
         asizeof.asized(obj,
                        align=align,
                        detail=detail,
                        code=code,
                        limit=limit))
Exemple #2
0
    def test_refs(self):
        '''Test asizeof.refs()
        '''
        f = Foo(42)
        refs = list(asizeof.refs(f))
        self.assertTrue(len(refs) >= 1, len(refs))
        self.assertTrue({'data': 42} in refs, refs)

        f = OldFoo(42)
        refs = list(asizeof.refs(f))
        self.assertTrue(len(refs) >= 1, len(refs))
        self.assertTrue({'odata': 42} in refs, refs)

        f = ThinFoo(42)
        refs = list(asizeof.refs(f))
        self.assertTrue(len(refs) >= 2, len(refs))
        self.assertTrue(42 in refs, refs)
Exemple #3
0
    def test_refs(self):
        '''Test asizeof.refs()
        '''
        f = Foo(42)
        refs = list(asizeof.refs(f))
        self.assertTrue(len(refs) >= 1, len(refs))
        self.assertTrue({'data': 42} in refs, refs)

        f = OldFoo(42)
        refs = list(asizeof.refs(f))
        self.assertTrue(len(refs) >= 1, len(refs))
        self.assertTrue({'odata': 42} in refs, refs)

        f = ThinFoo(42)
        refs = list(asizeof.refs(f))
        self.assertTrue(len(refs) >= 2, len(refs))
        self.assertTrue(42 in refs, refs)
Exemple #4
0
 def _print_functions(self, obj, name=None, align=8, detail=MAX, code=False, limit=MAX,
                           opt='', **unused):
     if name:
         self._printf('%sasizeof functions for %s ... %s', os.linesep, name, opt)
     self._printf('%s(): %s', ' basicsize', asizeof.basicsize(obj))
     self._printf('%s(): %s', ' itemsize',  asizeof.itemsize(obj))
     self._printf('%s(): %r', ' leng',      asizeof.leng(obj))
     self._printf('%s(): %s', ' refs',     _repr(asizeof.refs(obj)))
     self._printf('%s(): %s', ' flatsize',  asizeof.flatsize(obj, align=align))  # , code=code
     self._printf('%s(): %s', ' asized',           asizeof.asized(obj, align=align, detail=detail, code=code, limit=limit))