當前位置: 首頁>>代碼示例>>Python>>正文


Python sys.gettotalrefcount方法代碼示例

本文整理匯總了Python中sys.gettotalrefcount方法的典型用法代碼示例。如果您正苦於以下問題:Python sys.gettotalrefcount方法的具體用法?Python sys.gettotalrefcount怎麽用?Python sys.gettotalrefcount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sys的用法示例。


在下文中一共展示了sys.gettotalrefcount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _do_leak_tests

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def _do_leak_tests(self, result = None):
        try:
            gtrc = sys.gettotalrefcount
        except AttributeError:
            return # can't do leak tests in this build
        # Assume already called once, to prime any caches etc
        gc.collect()
        trc = gtrc()
        for i in range(self.num_leak_iters):
            self.real_test(result)
            if result.shouldStop:
                break
        del i # created after we remembered the refcount!
        # int division here means one or 2 stray references won't force 
        # failure, but one per loop
        gc.collect()
        lost = (gtrc() - trc) // self.num_leak_iters
        if lost < 0:
            msg = "LeakTest: %s appeared to gain %d references!!" % (self.real_test, -lost)
            result.addFailure(self.real_test, (AssertionError, msg, None))
        if lost > 0:
            msg = "LeakTest: %s lost %d references" % (self.real_test, lost)
            exc = AssertionError(msg)
            result.addFailure(self.real_test, (exc.__class__, exc, None)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:26,代碼來源:pywin32_testutil.py

示例2: testLeaksGencache

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def testLeaksGencache(self):
        try:
            gtrc = sys.gettotalrefcount
        except AttributeError:
            print "Please run this with python_d for leak tests"
            gtrc = lambda: 0
        # note creating self.object() should have consumed our "one time" leaks
        object = EnsureDispatch("Python.Test.Pippo")
        start = gtrc()
        for i in range(1000):
            object = EnsureDispatch("Python.Test.Pippo")
            object.Method1()
        object = None
        end = gtrc()
        if end-start > 10:
            self.fail("We lost %d references!" % (end-start,)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:18,代碼來源:testPippo.py

示例3: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    test_classes = (
        TestPartial,
        TestPartialSubclass,
        TestPythonPartial,
        TestUpdateWrapper,
        TestTotalOrdering,
        TestWraps,
        TestReduce,
    )
    test_support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:23,代碼來源:test_functools.py

示例4: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    from test import test_bisect

    test_classes = [TestBisectPython, TestBisectC,
                    TestInsortPython, TestInsortC,
                    TestErrorHandlingPython, TestErrorHandlingC]

    test_support.run_unittest(*test_classes)
    test_support.run_doctest(test_bisect, verbose)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:21,代碼來源:test_bisect.py

示例5: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    global numruns
    if not numruns:
        with check_py3k_warnings(
                (".+ not supported in 3.x", DeprecationWarning)):
            run_unittest(TestExecFile)
    numruns += 1
    test_classes = (BuiltinTest, TestSorted, TestType)

    _run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            _run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:22,代碼來源:test_builtin.py

示例6: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    test_classes = (
        TestBase,
        TestDecorateSortUndecorate,
        TestBugs,
    )

    with test_support.check_py3k_warnings(
            ("the cmp argument is not supported", DeprecationWarning)):
        test_support.run_unittest(*test_classes)

        # verify reference counting
        if verbose and hasattr(sys, "gettotalrefcount"):
            import gc
            counts = [None] * 5
            for i in xrange(len(counts)):
                test_support.run_unittest(*test_classes)
                gc.collect()
                counts[i] = sys.gettotalrefcount()
            print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:22,代碼來源:test_sort.py

示例7: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    import sys
    from test import test_support
    test_classes = (TestTranforms,)

    with test_support.check_py3k_warnings(
            ("backquote not supported", SyntaxWarning)):
        test_support.run_unittest(*test_classes)

        # verify reference counting
        if verbose and hasattr(sys, "gettotalrefcount"):
            import gc
            counts = [None] * 5
            for i in xrange(len(counts)):
                test_support.run_unittest(*test_classes)
                gc.collect()
                counts[i] = sys.gettotalrefcount()
            print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:20,代碼來源:test_peepholer.py

示例8: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
                    RegressionTests, LengthTransparency,
                    SubclassWithKwargsTest, TestExamples,
                    TestPurePythonRoughEquivalents)
    test_support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts

    # doctest the examples in the library reference
    test_support.run_doctest(sys.modules[__name__], verbose) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:21,代碼來源:test_itertools.py

示例9: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    import sys
    test_classes = (
        TestBasic,
        TestVariousIteratorArgs,
        TestSubclass,
        TestSubclassWithKwargs,
    )

    test_support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts

    # doctests
    from test import test_deque
    test_support.run_doctest(test_deque, verbose) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:26,代碼來源:test_deque.py

示例10: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    import sys
    test_classes = (
        OperatorTestCase,
    )

    test_support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:test_operator.py

示例11: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    testclasses =    [WichmannHill_TestBasicOps,
                      MersenneTwister_TestBasicOps,
                      TestDistributions,
                      TestModule]

    try:
        random.SystemRandom().random()
    except NotImplementedError:
        pass
    else:
        testclasses.append(SystemRandom_TestBasicOps)

    test_support.run_unittest(*testclasses)

    # verify reference counting
    import sys
    if verbose and hasattr(sys, "gettotalrefcount"):
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*testclasses)
            counts[i] = sys.gettotalrefcount()
        print counts 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:25,代碼來源:test_random.py

示例12: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
                    RegressionTests, LengthTransparency,
                    SubclassWithKwargsTest, TestExamples)
    test_support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            test_support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts

    # doctest the examples in the library reference
    test_support.run_doctest(sys.modules[__name__], verbose) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:20,代碼來源:test_itertools.py

示例13: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    global numruns
    if not numruns:
        with check_py3k_warnings(
                (".+ not supported in 3.x", DeprecationWarning)):
            run_unittest(TestExecFile)
    numruns += 1
    test_classes = (BuiltinTest, TestSorted)

    _run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in xrange(len(counts)):
            _run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print counts 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:22,代碼來源:test_builtin.py

示例14: test_main

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_main(verbose=None):
    test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
                    RegressionTests, LengthTransparency,
                    SubclassWithKwargsTest, TestExamples,
                    SizeofTest)
    support.run_unittest(*test_classes)

    # verify reference counting
    if verbose and hasattr(sys, "gettotalrefcount"):
        import gc
        counts = [None] * 5
        for i in range(len(counts)):
            support.run_unittest(*test_classes)
            gc.collect()
            counts[i] = sys.gettotalrefcount()
        print(counts)

    # doctest the examples in the library reference
    support.run_doctest(sys.modules[__name__], verbose) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:21,代碼來源:test_itertools.py

示例15: test_write

# 需要導入模塊: import sys [as 別名]
# 或者: from sys import gettotalrefcount [as 別名]
def test_write(self):
        delta = 0
        rows = [[1,2,3]]*5
        s = NUL()
        lastrc = sys.gettotalrefcount()
        for i in range(20):
            gc.collect()
            self.assertEqual(gc.garbage, [])
            rc = sys.gettotalrefcount()
            writer = csv.writer(s)
            for row in rows:
                writer.writerow(row)
            delta = rc-lastrc
            lastrc = rc
        # if writer leaks during write, last delta should be 5 or more
        self.assertEqual(delta < 5, True) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:18,代碼來源:test_csv.py


注:本文中的sys.gettotalrefcount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。