Skip to main content

TimePinner的存根

Project description

简介

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

TimePinner-stubs-0.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

TimePinner_stubs-0.0.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file TimePinner-stubs-0.0.1.tar.gz.

File metadata

  • Download URL: TimePinner-stubs-0.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.1

File hashes

Hashes for TimePinner-stubs-0.0.1.tar.gz
Algorithm Hash digest
SHA256 15c79f54ee622a6742ae03c8df7d98aa5438a1e3f0396d6156027d2c8415e897
MD5 18c000b400f49f1da40dbd8b7d061535
BLAKE2b-256 79d80a87276a85886a3954f81da50154a689df6cf955bbb8db1635f7a747de78

See more details on using hashes here.

File details

Details for the file TimePinner_stubs-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for TimePinner_stubs-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88c8dd6064e6b9742c6e6e4f7dc71a707138f93570c09a45e3f3204568aef40a
MD5 b3459388e22fc961ba54b6ec133031eb
BLAKE2b-256 736f553d612c997c8b7911d65d85fa74354b515df6bd2e78d8e0bbcb6e05a8e3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page