# -*- coding: UTF-8 -*-
# 作者：huanhuilong
# 标题：Python 计时器
# 描述：便利的 Python 计时器，统计从 0 遍历到 100000 消耗的时间，精确到毫秒

import time


class TimeSpan:
    def __init__(self) -> None:
        self.start = round(time.time() * 1000)

    def elapse_mill_secs(self):
        end = round(time.time() * 1000)
        return end-self.start

    def elapse_secs(self):
        end = round(time.time() * 1000)
        return (end-self.start)/1000


if __name__ == '__main__':
    s = TimeSpan()

    for i in range(0, 100000):
        pass

    print('耗时： {} 毫秒'.format(s.elapse_mill_secs()))
    print('耗时： {} 秒'.format(s.elapse_secs()))
