duyan-debug


Nameduyan-debug JSON
Version 0.0.6 PyPI version JSON
download
home_pagehttps://github.com/pypa/sampleproject
SummaryUsing for Debug, finding problem
upload_time2022-12-28 05:52:05
maintainer
docs_urlNone
authorWuMenghao
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            #### 1、介绍

本工具用与日志记录python程序内存信息,包括内存对象数量(memory type num),内存对象增长(memory type num increment),以及堆内存信息(memory heap info)。

#### 2、使用方式
示例:
```python
import time

import debug_util


class Int:

    def __init__(self, value):
        self.value = value


def new_int(i1, rs1):
    a = Int(i1)
    rs1.append(a)


if __name__ == '__main__':
    ml = debug_util.memory_logger(log_file_name='test', duration=2)
    ml.add_target(debug_util.handlers.MEMORY_TYPE_NUM)
    ml.add_target(debug_util.handlers.MEMORY_TYPE_NUM_GROWTH)
    ml.add_target(debug_util.handlers.MEMORY_STACK)
    ml.start()
    rs = []
    i = 0
    while True:
        if i % 1000000 == 0:
            time.sleep(2)
        if i == 10000000:
            break
        new_int(i, rs)
        i += 1

```

查看log/test.log文件

```
=== types: 2022-04-06 15:19:54.733344 === 	
Int                1000000
function           7643
dict               4543
tuple              3687
weakref            3487
wrapper_descriptor 2308
list               2288
set                1516
method_descriptor  1392
getset_descriptor  1117
=== increments: 2022-04-06 15:19:56.057061 === 	
Int                 1601726  +1601726
function               7643     +7643
dict                   4543     +4543
tuple                  3686     +3686
weakref                3488     +3488
wrapper_descriptor     2308     +2308
list                   2288     +2288
set                    1516     +1516
method_descriptor      1392     +1392
getset_descriptor      1117     +1117
=== heap: 2022-04-06 15:19:57.694068 === 	
Partition of a set of 6196589 objects. Total size = 432261651 bytes.
 Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)
     0 2016955  33 225898960  52 225898960  52 dict of __main__.Int
     1 2016955  33 112949480  26 338848440  78 __main__.Int
     2 2019998  33 56568872  13 395417312  91 int
     3   2165   0 17903984   4 413321296  96 list
     4  45089   1  6041583   1 419362879  97 str
     5  35822   1  2708928   1 422071807  98 tuple
     6  17286   0  1296554   0 423368361  98 bytes
     7   8675   0  1254272   0 424622633  98 types.CodeType
     8   8439   0  1147704   0 425770337  98 function
     9   1116   0   984664   0 426755001  99 type
<393 more rows. Type e.g. '_.more' to view.> 	
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pypa/sampleproject",
    "name": "duyan-debug",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "WuMenghao",
    "author_email": "menghao.wu@duyansoft.com",
    "download_url": "https://files.pythonhosted.org/packages/e2/c9/e887b58ede995bbb91e1b4d5491e2b9dcd9cec98893991035c8301625a43/duyan-debug-0.0.6.tar.gz",
    "platform": null,
    "description": "#### 1\u3001\u4ecb\u7ecd\n\n\u672c\u5de5\u5177\u7528\u4e0e\u65e5\u5fd7\u8bb0\u5f55python\u7a0b\u5e8f\u5185\u5b58\u4fe1\u606f\uff0c\u5305\u62ec\u5185\u5b58\u5bf9\u8c61\u6570\u91cf(memory type num)\uff0c\u5185\u5b58\u5bf9\u8c61\u589e\u957f(memory type num increment)\uff0c\u4ee5\u53ca\u5806\u5185\u5b58\u4fe1\u606f(memory heap info)\u3002\n\n#### 2\u3001\u4f7f\u7528\u65b9\u5f0f\n\u793a\u4f8b\uff1a\n```python\nimport time\n\nimport debug_util\n\n\nclass Int:\n\n    def __init__(self, value):\n        self.value = value\n\n\ndef new_int(i1, rs1):\n    a = Int(i1)\n    rs1.append(a)\n\n\nif __name__ == '__main__':\n    ml = debug_util.memory_logger(log_file_name='test', duration=2)\n    ml.add_target(debug_util.handlers.MEMORY_TYPE_NUM)\n    ml.add_target(debug_util.handlers.MEMORY_TYPE_NUM_GROWTH)\n    ml.add_target(debug_util.handlers.MEMORY_STACK)\n    ml.start()\n    rs = []\n    i = 0\n    while True:\n        if i % 1000000 == 0:\n            time.sleep(2)\n        if i == 10000000:\n            break\n        new_int(i, rs)\n        i += 1\n\n```\n\n\u67e5\u770blog/test.log\u6587\u4ef6\n\n```\n=== types: 2022-04-06 15:19:54.733344 === \t\nInt                1000000\nfunction           7643\ndict               4543\ntuple              3687\nweakref            3487\nwrapper_descriptor 2308\nlist               2288\nset                1516\nmethod_descriptor  1392\ngetset_descriptor  1117\n=== increments: 2022-04-06 15:19:56.057061 === \t\nInt                 1601726  +1601726\nfunction               7643     +7643\ndict                   4543     +4543\ntuple                  3686     +3686\nweakref                3488     +3488\nwrapper_descriptor     2308     +2308\nlist                   2288     +2288\nset                    1516     +1516\nmethod_descriptor      1392     +1392\ngetset_descriptor      1117     +1117\n=== heap: 2022-04-06 15:19:57.694068 === \t\nPartition of a set of 6196589 objects. Total size = 432261651 bytes.\n Index  Count   %     Size   % Cumulative  % Kind (class / dict of class)\n     0 2016955  33 225898960  52 225898960  52 dict of __main__.Int\n     1 2016955  33 112949480  26 338848440  78 __main__.Int\n     2 2019998  33 56568872  13 395417312  91 int\n     3   2165   0 17903984   4 413321296  96 list\n     4  45089   1  6041583   1 419362879  97 str\n     5  35822   1  2708928   1 422071807  98 tuple\n     6  17286   0  1296554   0 423368361  98 bytes\n     7   8675   0  1254272   0 424622633  98 types.CodeType\n     8   8439   0  1147704   0 425770337  98 function\n     9   1116   0   984664   0 426755001  99 type\n<393 more rows. Type e.g. '_.more' to view.> \t\n```\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Using for Debug, finding problem",
    "version": "0.0.6",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "5a9bc18915d42c05c743926012e1784e",
                "sha256": "d291abbcbf6acc8b2fa58174f54904b4d0d93e1642e764fc064841e26022988a"
            },
            "downloads": -1,
            "filename": "duyan_debug-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5a9bc18915d42c05c743926012e1784e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 5300,
            "upload_time": "2022-12-28T05:52:03",
            "upload_time_iso_8601": "2022-12-28T05:52:03.333706Z",
            "url": "https://files.pythonhosted.org/packages/4f/0a/e42483258d8f1cde3a68e3cc2f035713c8010f77d4a5413b675722ed0293/duyan_debug-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "848651a19dec1c95942b176e0fcf3e10",
                "sha256": "d6eb238c0d56e0024546872d1abdbe57aa3536eafabcf4c05a661f3398e51b23"
            },
            "downloads": -1,
            "filename": "duyan-debug-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "848651a19dec1c95942b176e0fcf3e10",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 40973,
            "upload_time": "2022-12-28T05:52:05",
            "upload_time_iso_8601": "2022-12-28T05:52:05.593852Z",
            "url": "https://files.pythonhosted.org/packages/e2/c9/e887b58ede995bbb91e1b4d5491e2b9dcd9cec98893991035c8301625a43/duyan-debug-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-28 05:52:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pypa",
    "github_project": "sampleproject",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "duyan-debug"
}
        
Elapsed time: 0.02659s