Пример #1
0
    def setUp(self):
        self.stdout = StringIO()
        self.profiler = Profiler(stdout=self.stdout)

        def func():
            """foo"""
            return "foo"

        def wrapper(*args, **kwargs):
            return func()

        self.func = func
        self.wrapper = wrapper
Пример #2
0
class TestProfiler(tests.BaseTest):
    def setUp(self):
        self.stdout = StringIO()
        self.profiler = Profiler(stdout=self.stdout)

        def func():
            """foo"""
            return "foo"

        def wrapper(*args, **kwargs):
            return func()

        self.func = func
        self.wrapper = wrapper

    def test_wrap(self):
        wrapped = self.profiler.wrap(self.wrapper, self.func)
        self.assertEqual(wrapped(), "foo")
        self.assertEqual(wrapped.__doc__, self.func.__doc__)

    def test_anon_wrap(self):
        def __profiler_func():
            """foo"""
            return "foo"

        wrapped = self.profiler.wrap(self.wrapper, __profiler_func)
        self.assertEqual(wrapped, "foo")

    def test_deterministic(self):
        # Sanity check...
        @self.profiler.deterministic
        def foo():
            pass

        foo()

    def test_statistical(self):
        # Sanity check...
        @self.profiler.statistical
        def foo():
            pass

        foo()
Пример #3
0
    def setUp(self):
        self.stdout = StringIO()
        self.profiler = Profiler(stdout=self.stdout)

        def func():
            """foo"""
            return "foo"

        def wrapper(*args, **kwargs):
            return func()
        self.func = func
        self.wrapper = wrapper
Пример #4
0
class TestProfiler(tests.BaseTest):

    def setUp(self):
        self.stdout = StringIO()
        self.profiler = Profiler(stdout=self.stdout)

        def func():
            """foo"""
            return "foo"

        def wrapper(*args, **kwargs):
            return func()
        self.func = func
        self.wrapper = wrapper

    def test_wrap(self):
        wrapped = self.profiler.wrap(self.wrapper, self.func)
        self.assertEqual(wrapped(), "foo")
        self.assertEqual(wrapped.__doc__, self.func.__doc__)

    def test_anon_wrap(self):
        def __profiler_func():
            """foo"""
            return "foo"
        wrapped = self.profiler.wrap(self.wrapper, __profiler_func)
        self.assertEqual(wrapped, "foo")

    def test_deterministic(self):
        # Sanity check...
        @self.profiler.deterministic
        def foo():
            pass
        foo()

    def test_statistical(self):
        # Sanity check...
        @self.profiler.statistical
        def foo():
            pass
        foo()