面向人类的python计时器模块。
marktime的Python项目详细描述
用于标记时间的简单python模块。
灵感来自node.js的两个函数:
主要功能:
- easy to use
- no external dependencies
- 100% test coverage
- works with Python 2.7 and 3.3
用法
$ pip install marktime
importmarktimemarktime.start('some task')marktime.start('some another task')marktime.stop('some task')8.757422924041748marktime.stop('some another task').seconds14.805735111236572marktime.duration('some another task').msecs14805.735111236572marktime.start('some task # 3')withmarktime.stopwatch('some task # 4'):marktime.time.sleep(1)importjsonprintjson.dumps(marktime.labels,indent=4){"some another task":{"duration":14.805735111236572,"start_time":1370453758.064955,"end_time":1370453772.87069},"some task # 3":{"start_time":1370453892.025603,"end_time":None},"some task # 4":{"duration":1.00120210647583,"start_time":1370638027.000799,"end_time":1370638028.002001},"some task":{"duration":8.757422924041748,"start_time":1370453753.185846,"end_time":1370453761.943269}}
API
- marktime.start(label,at=none)
- label-标记标签。弦。必修的。
- at-开始倒计时的时间。如果None,则使用time.time()。
- marktime.stop(label,remove_from_labels=false,stop_once=true)
- label-标记标签。弦。必修的。
- at-停止倒计时的时间。如果None,则使用time.time()
- remove_from_labels-如果True则label从全局中删除 dictmarktime.labels。
- stop_once-如果False和特定^{tt1}的倒计时$ 一切都准备好了,又停止了。此后 一定会增加label。
- marktime.duration(label,stop_it=true,stop_at=none)
- label-标记标签。弦。必修的。
- stop_it-如果True,则特定^{tt1}的倒计时$ 将被停止。如果False和特定^{tt1}的倒计时$ 不停止,则返回None。
- stop_at-如果stop_it=True
- marktime.stopwatch(label)-上下文管理器(withstatement支持)
- marktime.labels-globaldict存储时间标记的所有标签。
许可证
见LICENSE 文件。