test_timer.py 453 Bytes
Newer Older
limm's avatar
limm committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Copyright (c) OpenMMLab. All rights reserved.
import time

from mmdeploy.utils.timer import TimeCounter


def test_count_time():

    class test:

        @TimeCounter.count_time('fun1')
        def fun1(self):
            time.sleep(0.01)

    t = test()
    with TimeCounter.activate('fun1', warmup=10, log_interval=10):
        for i in range(50):
            t.fun1()

    for i in range(50):
        t.fun1()

    TimeCounter.print_stats('fun1')