TimePinner-stubs


NameTimePinner-stubs JSON
Version 0.0.1 PyPI version JSON
download
home_pagehttps://gitee.com/g1879/TimePinner
SummaryTimePinner的存根
upload_time2023-01-14 16:17:04
maintainer
docs_urlNone
authorg1879
requires_python>=3.6
licenseMIT
keywords stopwatch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 简介

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

类似于代码中的秒表。

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

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

# 安装与导入

## 安装

```python
pip install TimePinner
```

## 导入

```python
from TimePinner import Pinner
```

# 使用方法

## 创建对象

```python
from TimePinner import Pinner

pinner = Pinner()
```

## 记录时间点

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

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

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

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

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

输出:

```console
0.0
记录1:1.0084643
```

## 跳过时间段

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

```python
pinner.skip()
```

## 打印结果

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

```console
记录1:1.007383
记录2:2.0145351000000002
```

## 获取结果

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

```python
print(pinner.records)
```

输出:

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

## 获取最短的时间段

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

```python
print(pinner.winner)
```

输出:

```console
('记录1', 1.0084643)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitee.com/g1879/TimePinner",
    "name": "TimePinner-stubs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "stopwatch",
    "author": "g1879",
    "author_email": "g1879@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/79/d8/0a87276a85886a3954f81da50154a689df6cf955bbb8db1635f7a747de78/TimePinner-stubs-0.0.1.tar.gz",
    "platform": null,
    "description": "# \u7b80\u4ecb\r\n\r\nTimePinner \u662f\u4e00\u4e2a\u7b80\u5355\u7684\u8ba1\u65f6\u5de5\u5177\u3002\r\n\r\n\u7c7b\u4f3c\u4e8e\u4ee3\u7801\u4e2d\u7684\u79d2\u8868\u3002\r\n\r\n\u53ef\u6807\u8bb0\u591a\u4e2a\u70b9\uff0c\u4ee5\u8bb0\u5f55\u82e5\u5e72\u6bb5\u65f6\u95f4\u957f\u5ea6\u3002\r\n\r\n\u6bcf\u6bb5\u65f6\u95f4\u53ef\u4ee5\u547d\u540d\uff0c\u4ee5\u65b9\u4fbf\u8bb0\u5fc6\uff0c\u4e5f\u53ef\u8df3\u8fc7\u65e0\u987b\u8bb0\u5f55\u7684\u65f6\u95f4\u6bb5\u3002\r\n\r\n# \u5b89\u88c5\u4e0e\u5bfc\u5165\r\n\r\n## \u5b89\u88c5\r\n\r\n```python\r\npip install TimePinner\r\n```\r\n\r\n## \u5bfc\u5165\r\n\r\n```python\r\nfrom TimePinner import Pinner\r\n```\r\n\r\n# \u4f7f\u7528\u65b9\u6cd5\r\n\r\n## \u521b\u5efa\u5bf9\u8c61\r\n\r\n```python\r\nfrom TimePinner import Pinner\r\n\r\npinner = Pinner()\r\n```\r\n\r\n## \u8bb0\u5f55\u65f6\u95f4\u70b9\r\n\r\n\u4f7f\u7528`pin()`\u65b9\u6cd5\u8bb0\u5f55\u4e00\u4e2a\u65f6\u95f4\u70b9\uff0c\u53ef\u4ee5\u901a\u8fc7`text`\u53c2\u6570\u7ed9\u8be5\u65f6\u95f4\u70b9\u547d\u540d\u3002\r\n\r\n\u8bb0\u5f55\u7684\u65f6\u5019\u4f1a\u628a\u5f53\u524d\u65f6\u95f4\u6bb5\u6253\u5370\u51fa\u6765\uff0c\u53ef\u7528`show()`\u53c2\u6570\u8bbe\u7f6e\u4e0d\u6253\u5370\u3002\r\n\r\n\u4e5f\u53ef\u4ee5\u5728\u521b\u5efa\u5bf9\u8c61\u65f6\u7528`show_everytime`\u53c2\u6570\u8bbe\u7f6e\u662f\u5426\u6253\u5370\u3002\r\n\r\n`pin()`\u7684`show`\u53c2\u6570\u6bd4\u521b\u5efa\u5bf9\u8c61\u65f6`show_everytime`\u53c2\u6570\u4f18\u5148\u7ea7\u9ad8\u3002\r\n\r\n```python\r\npinner = Pinner()\r\npinner.pin()  # \u8bb0\u5f55\u8d77\u59cb\u70b9\r\nsleep(1)\r\npinner.pin('\u8bb0\u5f551')\r\nsleep(2)\r\npinner.pin('\u8bb0\u5f552', show=False)  # \u4e0d\u6253\u5370\u8be5\u8282\u70b9\r\n```\r\n\r\n\u8f93\u51fa\uff1a\r\n\r\n```console\r\n0.0\r\n\u8bb0\u5f551\uff1a1.0084643\r\n```\r\n\r\n## \u8df3\u8fc7\u65f6\u95f4\u6bb5\r\n\r\n\u6709\u4e9b\u65f6\u95f4\u6bb5\u65e0\u987b\u8bb0\u5f55\uff0c\u7528`skip()`\u65b9\u6cd5\u8df3\u8fc7\u3002\u4e0b\u4e00\u4e2a\u8bb0\u5f55\u4f1a\u4ee5\u5f53\u524d\u70b9\u4f5c\u4e3a\u8d77\u59cb\u3002\r\n\r\n```python\r\npinner.skip()\r\n```\r\n\r\n## \u6253\u5370\u7ed3\u679c\r\n\r\n\u901a\u8fc7`show()`\u65b9\u6cd5\uff0c\u53ef\u4ee5\u628a\u8bb0\u5f55\u5230\u7684\u65f6\u95f4\u6bb5\u6253\u5370\u51fa\u6765\u3002\r\n\r\n```console\r\n\u8bb0\u5f551\uff1a1.007383\r\n\u8bb0\u5f552\uff1a2.0145351000000002\r\n```\r\n\r\n## \u83b7\u53d6\u7ed3\u679c\r\n\r\n\u901a\u8fc7`records`\u5c5e\u6027\u83b7\u53d6\u5404\u4e2a\u8bb0\u5f55\u7684\u65f6\u95f4\u6bb5\uff0c\u6bcf\u4e2a\u65f6\u95f4\u6bb5\u4e3a\u4e00\u4e2a\u4e24\u4f4d\u5143\u7ec4\u3002\r\n\r\n```python\r\nprint(pinner.records)\r\n```\r\n\r\n\u8f93\u51fa\uff1a\r\n\r\n```console\r\n[('\u8bb0\u5f551', 1.0084643), ('\u8bb0\u5f552', 2.0126551999999998)]\r\n```\r\n\r\n## \u83b7\u53d6\u6700\u77ed\u7684\u65f6\u95f4\u6bb5\r\n\r\n\u901a\u8fc7`winner`\u5c5e\u6027\u53ef\u4ee5\u83b7\u53d6\u6700\u77ed\u7684\u65f6\u95f4\u6bb5\uff0c\u7528\u4e8e\u5bf9\u6bd4\u51e0\u6bb5\u4ee3\u7801\u8fd0\u884c\u65f6\u95f4\u3002\r\n\r\n```python\r\nprint(pinner.winner)\r\n```\r\n\r\n\u8f93\u51fa\uff1a\r\n\r\n```console\r\n('\u8bb0\u5f551', 1.0084643)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "TimePinner\u7684\u5b58\u6839",
    "version": "0.0.1",
    "split_keywords": [
        "stopwatch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "736f553d612c997c8b7911d65d85fa74354b515df6bd2e78d8e0bbcb6e05a8e3",
                "md5": "b3459388e22fc961ba54b6ec133031eb",
                "sha256": "88c8dd6064e6b9742c6e6e4f7dc71a707138f93570c09a45e3f3204568aef40a"
            },
            "downloads": -1,
            "filename": "TimePinner_stubs-0.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b3459388e22fc961ba54b6ec133031eb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 4900,
            "upload_time": "2023-01-14T16:17:02",
            "upload_time_iso_8601": "2023-01-14T16:17:02.851848Z",
            "url": "https://files.pythonhosted.org/packages/73/6f/553d612c997c8b7911d65d85fa74354b515df6bd2e78d8e0bbcb6e05a8e3/TimePinner_stubs-0.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "79d80a87276a85886a3954f81da50154a689df6cf955bbb8db1635f7a747de78",
                "md5": "18c000b400f49f1da40dbd8b7d061535",
                "sha256": "15c79f54ee622a6742ae03c8df7d98aa5438a1e3f0396d6156027d2c8415e897"
            },
            "downloads": -1,
            "filename": "TimePinner-stubs-0.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "18c000b400f49f1da40dbd8b7d061535",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 3376,
            "upload_time": "2023-01-14T16:17:04",
            "upload_time_iso_8601": "2023-01-14T16:17:04.726150Z",
            "url": "https://files.pythonhosted.org/packages/79/d8/0a87276a85886a3954f81da50154a689df6cf955bbb8db1635f7a747de78/TimePinner-stubs-0.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-14 16:17:04",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "timepinner-stubs"
}
        
Elapsed time: 0.13108s