跳转到主要内容

计数工具

项目描述

https://travis-ci.org/lorien/statx.png?branch=master https://img.shields.io/pypi/dm/statx.svg https://img.shields.io/pypi/v/statx.svg https://readthedocs.org/projects/statx/badge/?version=latest

什么是statx库?

您可能会发现收集有关某些长时间运行过程(例如网站爬取、复制大量文件、处理某些大型数据)的统计信息很有用。Stat类能够

* count things
* display speed of change
* collects things (collections are also counted)

使用示例

>>> from statx import Stat
>>> import time
>>> import logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> stat = Stat(speed_key='foo')
>>> for x in range(20):
...     stat.inc('foo')
...     stat.inc('bar', 2)
...     stat.collect('gaz', 13)
...     time.sleep(0.5)
...
DEBUG:grab.stat:RPS: 0.01 [bar=82, foo=42]
DEBUG:grab.stat:RPS: 2.00 [bar=86, foo=44, gaz=2]
DEBUG:grab.stat:RPS: 2.00 [bar=90, foo=46, gaz=4]
DEBUG:grab.stat:RPS: 2.00 [bar=94, foo=48, gaz=6]
DEBUG:grab.stat:RPS: 2.00 [bar=98, foo=50, gaz=8]
DEBUG:grab.stat:RPS: 2.00 [bar=102, foo=52, gaz=10]
DEBUG:grab.stat:RPS: 2.00 [bar=106, foo=54, gaz=12]
DEBUG:grab.stat:RPS: 2.00 [bar=110, foo=56, gaz=14]
DEBUG:grab.stat:RPS: 2.00 [bar=114, foo=58, gaz=16]
DEBUG:grab.stat:RPS: 2.00 [bar=118, foo=60, gaz=18]
>>> stat.print_progress_line()
DEBUG:grab.stat:RPS: 0.04 [bar=122, foo=61, gaz=20]
>>> stat.counters
defaultdict(<type 'int'>, {'foo': 61, 'bar': 122})
>>> stat.collections
defaultdict(<type 'list'>, {'gaz': [13, 13, 13, 13, 13, 13, 13, 13, 13,
                                    13, 13, 13, 13, 13, 13, 13, 13, 13,
                                    13, 13]})

安装

使用pip

$ pip install -U statx

贡献

使用github提交错误、修复或愿望请求: https://github.com/lorien/statx/issues

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

statx-0.0.2.tar.gz (3.5 kB 查看哈希值)

由以下支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面