Example #1
0
    def test_stopwatch(self):
        diff_time = 0.5
        with marktime.stopwatch('test_stopwatch'):
            time.sleep(diff_time)

        self.assertEquals(round(marktime.duration('test_stopwatch').sec, 2),
                          round(diff_time, 2))
Example #2
0
    def test_duration(self):
        start_time = 1370451294
        diff_time = round(random.random() * 100)
        stop_time = start_time + diff_time

        marktime.start('test run', at=start_time)
        marktime.stop('test run', at=stop_time)
        self.assertEquals(marktime.duration('test run').seconds, diff_time)
Example #3
0
    def test_stopwatch(self):
        diff_time = 0.5
        with marktime.stopwatch('test_stopwatch'):
            time.sleep(diff_time)

        self.assertEquals(
            round(marktime.duration('test_stopwatch').seconds, 2),
            round(diff_time, 2))
Example #4
0
    def test_duration_with_stop(self):
        start_time = 1370451294
        diff_time = round(random.random() * 100)
        stop_time = start_time + diff_time

        marktime.start('test run', at=start_time)
        self.assertEquals(
            marktime.duration('test run', stop_it=True, stop_at=stop_time).sec,
            diff_time)
Example #5
0
    def test_duration_with_stop(self):
        start_time = 1370451294
        diff_time = round(random.random() * 100)
        stop_time = start_time + diff_time

        marktime.start('test run', at=start_time)
        self.assertEquals(
            marktime.duration('test run', stop_it=True,
                              stop_at=stop_time).sec,
            diff_time)
Example #6
0
 def test_duration_None(self):
     marktime.start('test run')
     self.assertIsNone(marktime.duration('test run', stop_it=False))
Example #7
0
 def test_duration_label_not_exists(self):
     self.assertIsNone(marktime.duration('not existance label'))
Example #8
0
'''
import marktime # stopwatch
from multiprocessing.pool import ThreadPool

def foo(bar, baz):
    print('hello {0}'.format(bar))
    return 'foo' + baz

def foo2(bar, baz):
    print('hello2 ' + bar)
    return 'foo2 ' + baz

def main():
    pool = ThreadPool(processes=1)
    async_result = pool.apply_async(foo, ('world', 'foo')) # tuple of args for foo
    async_result2 = pool.apply_async(foo2, ('world', 'foo2'))

    # do some other stuff in the main process

    return_val = async_result.get()  # get the return value from your function.
    return_val2 = async_result2.get()

    print(return_val)
    print(return_val2)

if __name__ == "__main__":
    marktime.start('task')
    main()
    marktime.stop('task')
    print(marktime.duration('task').msecs)