Skip to main content

A simple loop execution time measurement tool.

Project description

LoopTick

一个简单的 Python 循环耗时测量工具。

安装

pip install looptick

本地安装

git clone https://github.com/DBinK/LoopTick
pip install -e .

使用示例

常规方式

from looptick import LoopTick
import time

timer = LoopTick()
for i in range(5):
    diff = timer.tick()
    print(f"第 {i} 次循环耗时: {diff * timer.NS2MS:.6f} ms")
    time.sleep(0.01)

timer.__exit__()

使用上下文方式

from looptick import LoopTick
import time

with LoopTick() as timer:
    for i in range(5):
        diff = timer.tick()
        print(f"第 {i} 次循环耗时: {diff * timer.NS2MS:.6f} ms")
        time.sleep(0.01)

输出结果:

(LoopTick) PS C:\IT\LoopTick> & C:\IT\LoopTick\.venv\Scripts\python.exe c:/IT/LoopTick/examples/with_usage.py   0 次循环耗时: 0.000000 ms
第 1 次循环耗时: 10.829900 ms
第 2 次循环耗时: 16.055800 ms
第 3 次循环耗时: 14.013400 ms
第 4 次循环耗时: 15.587100 ms
总耗时: 0.056486 秒
平均耗时: 14.121550 ms

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

looptick-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

looptick-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file looptick-0.1.0.tar.gz.

File metadata

  • Download URL: looptick-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for looptick-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bb9578ea8e9538576a93c30f3ca0f47c7d5f73222436a2b5c64fc679c175493f
MD5 029d1e831f3648855000437002f3b62a
BLAKE2b-256 fa61123f58b35b662fce9606e3516c98a94e1590269e2e2a3348ce813668daac

See more details on using hashes here.

Provenance

The following attestation bundles were made for looptick-0.1.0.tar.gz:

Publisher: python-publish.yml on DBinK/LoopTick

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file looptick-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: looptick-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for looptick-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61d1aac2b7c3b31bf866aa4c84491b42812cde2389a0808624c1ddc91c582684
MD5 31e3d2068d4a5cc909a1cb144397562b
BLAKE2b-256 40cdccbd7301248463dfc241450dfac84446b9fe635c0d034fba092fdb8234e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for looptick-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on DBinK/LoopTick

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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