Exemplo n.º 1
0
    def test_example7(self):
        with get_chronograph("hello") as f:
            import time
            time.sleep(1)

        self.assertAlmostEqual(
            get_chronograph("hello").total_elapsed_time, 1.0, 1)
Exemplo n.º 2
0
    def test_example9(self):
        @add_chronograph()
        def func1():
            time.sleep(0.5)

        @add_chronograph(name="my func2 timer")
        def func2():
            time.sleep(0.25)

        func1()
        func1()
        func1()
        func2()

        cg1 = get_chronograph("func1")
        self.assertAlmostEqual(cg1.total_elapsed_time, 1.5, 1)
        self.assertEqual(len(cg1.timing_data), 3)

        cg2 = get_chronograph("my func2 timer")
        self.assertAlmostEqual(cg2.total_elapsed_time, 0.25, 1)
Exemplo n.º 3
0
    def test_example6(self):
        def func1():
            cg = get_chronograph("my first chronograph")
            cg.start()
            time.sleep(0.5)
            cg.stop()

        def func2():
            cg = get_chronograph("my second chronograph")
            cg.start()
            time.sleep(0.25)
            cg.stop()

        cg1 = get_chronograph("my first chronograph", start_timing=True)
        time.sleep(0.75)
        cg1.stop()
        func1()
        func2()

        self.assertAlmostEqual(cg1.total_elapsed_time, 1.25, 1)

        cg2 = get_chronograph("my second chronograph")
        self.assertAlmostEqual(cg2.total_elapsed_time, 0.25, 1)
Exemplo n.º 4
0
 def func2():
     cg = get_chronograph("my second chronograph")
     cg.start()
     time.sleep(0.25)
     cg.stop()
Exemplo n.º 5
0
 def func1():
     cg = get_chronograph("my first chronograph")
     cg.start()
     time.sleep(0.5)
     cg.stop()