Skip to main content

简介

TimePinner 是一个简单的计时工具。

类似于代码中的秒表。

可标记多个点,以记录若干段时间长度。

每段时间可以命名,以方便记忆,也可跳过无须记录的时间段。

安装与导入

安装

pip install TimePinner

导入

from TimePinner import Pinner

使用方法

创建对象

from TimePinner import Pinner

pinner = Pinner()

记录时间点

使用pin()方法记录一个时间点,可以通过text参数给该时间点命名。

记录的时候会把当前时间段打印出来,可用show()参数设置不打印。

也可以在创建对象时用show_everytime参数设置是否打印。

pin()的show参数比创建对象时show_everytime参数优先级高。

pinner = Pinner()
pinner.pin()  # 记录起始点
sleep(1)
pinner.pin('记录1')
sleep(2)
pinner.pin('记录2', show=False)  # 不打印该节点

输出:

0.0
记录1:1.0084643

跳过时间段

有些时间段无须记录,用skip()方法跳过。下一个记录会以当前点作为起始。

pinner.skip()

打印结果

通过show()方法,可以把记录到的时间段打印出来。

记录1:1.007383
记录2:2.0145351000000002

获取结果

通过records属性获取各个记录的时间段,每个时间段为一个两位元组。

print(pinner.records)

输出:

[('记录1', 1.0084643), ('记录2', 2.0126551999999998)]

获取最短的时间段

通过winner属性可以获取最短的时间段,用于对比几段代码运行时间。

print(pinner.winner)

输出:

('记录1', 1.0084643)

Metadata

Release files for TimePinner-stubs 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TimePinner-stubs 0.0.1
File Size Uploaded
TimePinner-stubs-0.0.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for TimePinner-stubs 0.0.1
File Interpreter ABI Platform
TimePinner_stubs-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / TimePinner-stubs-0.0.1.tar.gz

Download URL TimePinner-stubs-0.0.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
15c79f54ee622a6742ae03c8df7d98aa5438a1e3f0396d6156027d2c8415e897
BLAKE2b-256 checksum
How to use checksums
79d80a87276a85886a3954f81da50154a689df6cf955bbb8db1635f7a747de78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release files / TimePinner_stubs-0.0.1-py3-none-any.whl

Download URL TimePinner_stubs-0.0.1-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88c8dd6064e6b9742c6e6e4f7dc71a707138f93570c09a45e3f3204568aef40a
BLAKE2b-256 checksum
How to use checksums
736f553d612c997c8b7911d65d85fa74354b515df6bd2e78d8e0bbcb6e05a8e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page