{ "info": { "author": "Mathieu Turcotte", "author_email": "turcotte.mat@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: General" ], "description": "Massif Parser\r\n=============\r\n\r\nA parser for Valgrind massif.out files.\r\n\r\nThe msparser module offers a simple interface to parse the Valgrind massif.out\r\nfile format, i.e. data files produced by the valgrind heap profiler and should be \r\ncompatible with Python 2.5 and up (including 3.x and pypy).\r\n\r\nHow do I use it?\r\n----------------\r\n\r\nImport the module\r\n`````````````````\r\nAs usual, import the module::\r\n\r\n >>> import msparser\r\n\r\nParse a massif.out file\r\n```````````````````````\r\nTo extract the data from a massif.out file, you simply have to give its path to\r\nthe ``parse_file`` function::\r\n\r\n >>> data = msparser.parse_file('massif.out')\r\n\r\nYou could also use the ``msparser.parse`` function directly with a file\r\ndescriptor.\r\n\r\nUnderstand the data\r\n```````````````````\r\n\r\nThe parsed data is returned as a dictionary which follow closely the massif.out\r\nformat. It looks like this::\r\n\r\n >>> from pprint import pprint\r\n >>> pprint(data, depth=1)\r\n {'cmd': './a.out',\r\n 'desc': '--time-unit=ms',\r\n 'detailed_snapshots_index': [...],\r\n 'peak_snapshot_index': 16,\r\n 'snapshots': [...],\r\n 'time_unit': 'ms'}\r\n\r\nThe ``detailed_snapshots_index`` and ``peak_snapshot_index`` fields allow\r\nefficient localisation of the detailled and peak snapshots in the ``snapshots``\r\nlist. For example, to retrieve the peak snapshot from the ``snapshots`` list,\r\nwe could do::\r\n\r\n >>> peak_index = data['peak_snapshot_index']\r\n >>> peak_snapshot = data['snapshots'][peak_index]\r\n\r\nThe ``snapshots`` list stores dictionaries representing each snapshot data::\r\n\r\n >>> second_snapshot = data['snapshots'][1]\r\n >>> pprint(second_snapshot)\r\n {'heap_tree': None,\r\n 'id': 1,\r\n 'mem_heap': 1000,\r\n 'mem_heap_extra': 8,\r\n 'mem_stack': 0,\r\n 'time': 183}\r\n\r\nIf the snapshot is detailled, the ``heap_tree`` field, instead of being None,\r\nwill store a heap tree::\r\n\r\n >>> peak_heap_tree = peak_snapshot['heap_tree']\r\n >>> pprint(peak_heap_tree, depth=3)\r\n {'children': [{'children': [...], 'details': {...}, 'nbytes': 12000},\r\n {'children': [], 'details': {...}, 'nbytes': 10000},\r\n {'children': [...], 'details': {...}, 'nbytes': 8000},\r\n {'children': [...], 'details': {...}, 'nbytes': 2000}],\r\n 'details': None,\r\n 'nbytes': 32000}\r\n\r\nOn the root node, the ``details`` field is always None, but on the children\r\nnodes it's a dictionary which looks like this::\r\n\r\n >>> first_child = peak_snapshot['heap_tree']['children'][0]\r\n >>> pprint(first_child['details'], width=1)\r\n {'address': '0x8048404',\r\n 'file': 'prog.c',\r\n 'function': 'h',\r\n 'line': 4}\r\n\r\nObviously, if the node is below the massif threshold, the ``details`` field\r\nwill be None.\r\n\r\nPutting It All Together\r\n```````````````````````\r\nFrom this data structure, it's very easy to write a procedure that produce a\r\ndata table ready for Gnuplot consumption::\r\n\r\n print(\"# valgrind --tool=massif\", data['desc'], data['cmd'])\r\n print(\"# id\", \"time\", \"heap\", \"extra\", \"total\", \"stack\", sep='\\t')\r\n for snapshot in data['snapshots']:\r\n id = snapshot['id']\r\n time = snapshot['time']\r\n heap = snapshot['mem_heap']\r\n extra = snapshot['mem_heap_extra']\r\n total = heap + extra\r\n stack = snapshot['mem_stack']\r\n print(' '+str(id), time, heap, extra, total, stack, sep='\\t')\r\n\r\nThe output should looks like this::\r\n\r\n # valgrind --tool=massif --time-unit=ms ./a.out\r\n # id time heap extra total stack\r\n 0 0 0 0 0 0\r\n 1 183 1000 8 1008 0\r\n 2 184 2000 16 2016 0\r\n 3 184 3000 24 3024 0\r\n 4 184 4000 32 4032 0\r\n 5 184 5000 40 5040 0\r\n 6 184 6000 48 6048 0\r\n 7 184 7000 56 7056 0\r\n 8 184 8000 64 8064 0\r\n 9 184 9000 72 9072 0\r\n\r\nTests\r\n-----\r\n\r\nTo run msparser's test suite::\r\n\r\n $ python msparser_test.py --verbose\r\n\r\nThe current build status on travis: http://travis-ci.org/#!/MathieuTurcotte/msparser\r\n\r\nLicense\r\n-------\r\n\r\nThis code is free to use under the terms of the `MIT license `_.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MathieuTurcotte/msparser", "keywords": "valgrind,massif,parser", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "msparser", "package_url": "https://pypi.org/project/msparser/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/msparser/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/MathieuTurcotte/msparser" }, "release_url": "https://pypi.org/project/msparser/1.4/", "requires_dist": null, "requires_python": null, "summary": "Valgrind massif.out parser", "version": "1.4" }, "last_serial": 795065, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "caa61a53cb128fdaebc57d901ebf2002", "sha256": "e9855c65f579bf1e21c0d68c021888ba1fc9bd7aa459d3a67266331c76a11501" }, "downloads": -1, "filename": "msparser-1.0.tar.gz", "has_sig": false, "md5_digest": "caa61a53cb128fdaebc57d901ebf2002", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5307, "upload_time": "2011-01-12T21:42:01", "url": "https://files.pythonhosted.org/packages/25/6d/fdd0cc1466999c94e1a5bd624267fb6828b5c08dfdd9e78d9b7d3ee9e3aa/msparser-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "1508db289b914284db83755f44aede9e", "sha256": "8688b36d999e64863a60343f5032ecfca3f8f66ed5c883c91e3b1bacb702fb5b" }, "downloads": -1, "filename": "msparser-1.1.tar.gz", "has_sig": false, "md5_digest": "1508db289b914284db83755f44aede9e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5449, "upload_time": "2011-01-13T22:23:35", "url": "https://files.pythonhosted.org/packages/14/d7/f4121147cd78cf98aa7aea629634944ba4755a578d9847d12dc06cb52698/msparser-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "c04be4e81578355d2fbd6e91bafa7285", "sha256": "e6e1cffa2dbb3ea5398d79923be77923f53bc137429a3e74966e6b7c99932d43" }, "downloads": -1, "filename": "msparser-1.2.tar.gz", "has_sig": false, "md5_digest": "c04be4e81578355d2fbd6e91bafa7285", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6704, "upload_time": "2012-09-02T19:28:07", "url": "https://files.pythonhosted.org/packages/96/52/4f3efcfd125e3fa138dc259e643616fb652cf6b362305ffa1a1c4bb09b78/msparser-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "221d9aa67e87f05cefda3f5c7bb3029d", "sha256": "61767227edf86cb6f41f374c8fe171d87382fbfa7adefa8d70542d34da2c7ec9" }, "downloads": -1, "filename": "msparser-1.3.tar.gz", "has_sig": false, "md5_digest": "221d9aa67e87f05cefda3f5c7bb3029d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7370, "upload_time": "2012-10-19T01:41:02", "url": "https://files.pythonhosted.org/packages/df/01/3f7dcd78dccdcf04933e2fbb05570e286b4033b3555624d0340bafc5ac6c/msparser-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "764ada38bcf0574f14dd6934eae41822", "sha256": "1199d27bdc492647d2d17d7776e49176f3ec3d2d959d4cfc8b2ce9257cefc16f" }, "downloads": -1, "filename": "msparser-1.4.tar.gz", "has_sig": false, "md5_digest": "764ada38bcf0574f14dd6934eae41822", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7394, "upload_time": "2012-10-27T14:53:15", "url": "https://files.pythonhosted.org/packages/e0/68/aece1c5e75b49d95f304d2df029ae69583ef59a55694ec683e2452d70637/msparser-1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "764ada38bcf0574f14dd6934eae41822", "sha256": "1199d27bdc492647d2d17d7776e49176f3ec3d2d959d4cfc8b2ce9257cefc16f" }, "downloads": -1, "filename": "msparser-1.4.tar.gz", "has_sig": false, "md5_digest": "764ada38bcf0574f14dd6934eae41822", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7394, "upload_time": "2012-10-27T14:53:15", "url": "https://files.pythonhosted.org/packages/e0/68/aece1c5e75b49d95f304d2df029ae69583ef59a55694ec683e2452d70637/msparser-1.4.tar.gz" } ] }