Name | xunter JSON |
Version |
0.2.3
JSON |
| download |
home_page | https://github.com/anki-code/xunter |
Summary | Profiling for the xonsh shell based on hunter. |
upload_time | 2024-05-04 02:53:51 |
maintainer | None |
docs_url | None |
author | anki-code |
requires_python | >=3.6 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<p align="center">
<b>xunter</b> is to profiling <a href="https://xon.sh">xonsh shell</a> using <a href="https://github.com/ionelmc/python-hunter">hunter</a>. Time tracking is on board.
</p>
<p align="center">
If you like the idea click ⭐ on the repo and <a href="https://twitter.com/intent/tweet?text=Trace%20xonsh%20shell%20code!&url=https://github.com/anki-code/xunter" target="_blank">tweet</a>.
</p>
## Install
Install xunter into the environment where xonsh you want to trace resides.
```xsh
pip install xunter
# or: pip install git+https://github.com/anki-code/xunter
```
## Usage
Xunter is working as drop-in replacement of `xonsh` with additional arguments:
```xsh
xonsh --no-rc -c "2+2"
xunter --no-rc -c "2+2" ++depth-lt 5
# ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^
# xonsh xunter
```
Simple examples:
```xsh
xunter --no-rc -c "2+2" ++depth-lt 10
xunter --no-rc ++depth-lt 5 ++output /tmp/22.xun
xunter --no-rc -c '2+2' ++filter 'Q(filename_endswith="main.py")'
```
To set `++filter` read about [filters](https://python-hunter.readthedocs.io/en/latest/filtering.html)
and take a look into the [cookbook](https://python-hunter.readthedocs.io/en/latest/cookbook.html).
Use `./playground/trace.py` to experiment with the tracing filters and understand how it works.
#### Trace xonsh in the current directory
```xsh
mkdir -p ~/git/ && cd ~/git/
git clone git+https://github.com/xonsh/xonsh
cd xonsh
xunter --no-rc -c '1+1' ++cwd ++filter 'Q(filename_has="procs/")' ++output /tmp/out.xun
# Trace ./xonsh
# In another terminal:
tail -f /tmp/out.xun
```
#### Find function calls
```xsh
xunter --no-rc -c 'echo 1' ++filter 'Q(filename_has="specs.py")' ++output /tmp/specs.xun
cat /tmp/specs.xun | grep run_subproc
# [...]/site-packages/xonsh/procs/specs.py:910:run_subproc
# <= xonsh/built_ins.py:206:subproc_captured_hiddenobject
# <= <string>:1:<module> <= xonsh/codecache.py:64:run_compiled_code
# <= xonsh/codecache.py:218:run_code_with_cache
# <= xonsh/main.py:519:main_xonsh
# <= xonsh/main.py:470:main
# <= xunter/xunter:91:<module>
# - time_sec=[0.1505]
# Don't forget about xonsh`s awesome macro call:
xunter --no-rc -c 'echo 1' ++printer call ++filter! Q(filename_has="specs.py"),Q(function="run_subproc")
```
#### Filter code from prompt-toolkit and unwanted libs
```xsh
# These `filename` filters will be applied to the code that executed at the end.
# i.e. `filename="a.py"` will filter `a.py:func <= b.py:func <= c.py:func`
# but `c.py:func <= a.py:func <= b.py:func` case (`a.py` in the middle) wont be filtered.
filters = [
'~Q(filename_has="prompt_toolkit/")',
'~Q(filename_has="prompt/")',
'~Q(filename_has="ptk_shell/")',
'~Q(filename_has="pygments")',
'~Q(filename_has="_distutils_hack")',
'~Q(filename_has="lazyasd")',
'~Q(filename_has="environ")',
'~Q(filename_has="layout")',
]
xunter --no-rc ++filter @(','.join(filters)) ++output /tmp/1.xun
# Run in another terminal to monitor the activity:
tail -f /tmp/1.xun # | grep -i func
```
#### Time profiling
```xsh
xunter --no-rc -c 'echo 1' ++time-sec-gt 0.1 ++depth-lt 2
# ... - time_sec=[1.3710]
```
#### Convert log to table
```python
xunter --no-rc -c "2+2" ++depth-lt 10 ++printer stack ++output /tmp/22.xun
xunter2excel /tmp/22.xun
```
## Known issues
If you see the unexpected exceptions try to install xonsh from the main branch first.
## See also
* [xonsh-cheatsheet](https://github.com/anki-code/xonsh-cheatsheet)
* [xonsh-install](https://github.com/anki-code/xonsh-install)
* [How to debug xonsh interactively in IDE PyCharm](https://github.com/xonsh/xonsh/issues/3090#issuecomment-2068043223)
* By putting `import ipdb; ipdb.set_trace()` into any place of code you can investigate the environment interactively.
* xonsh builtin [`trace`](https://xon.sh/aliases.html#trace)
Raw data
{
"_id": null,
"home_page": "https://github.com/anki-code/xunter",
"name": "xunter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "anki-code",
"author_email": "no@no.no",
"download_url": "https://files.pythonhosted.org/packages/ed/b0/bf70dbf24bf1ed1efc36e2222e2a5be6f2bafc90db4cd23dd2bff9d8989d/xunter-0.2.3.tar.gz",
"platform": "any",
"description": "<p align=\"center\">\n<b>xunter</b> is to profiling <a href=\"https://xon.sh\">xonsh shell</a> using <a href=\"https://github.com/ionelmc/python-hunter\">hunter</a>. Time tracking is on board.\n</p>\n\n<p align=\"center\"> \nIf you like the idea click \u2b50 on the repo and <a href=\"https://twitter.com/intent/tweet?text=Trace%20xonsh%20shell%20code!&url=https://github.com/anki-code/xunter\" target=\"_blank\">tweet</a>.\n</p>\n\n## Install\n\nInstall xunter into the environment where xonsh you want to trace resides.\n\n```xsh\npip install xunter\n# or: pip install git+https://github.com/anki-code/xunter\n```\n\n## Usage\n\nXunter is working as drop-in replacement of `xonsh` with additional arguments:\n```xsh\nxonsh --no-rc -c \"2+2\"\nxunter --no-rc -c \"2+2\" ++depth-lt 5\n# ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^\n# xonsh xunter\n```\nSimple examples:\n```xsh\nxunter --no-rc -c \"2+2\" ++depth-lt 10\nxunter --no-rc ++depth-lt 5 ++output /tmp/22.xun\nxunter --no-rc -c '2+2' ++filter 'Q(filename_endswith=\"main.py\")'\n```\nTo set `++filter` read about [filters](https://python-hunter.readthedocs.io/en/latest/filtering.html) \nand take a look into the [cookbook](https://python-hunter.readthedocs.io/en/latest/cookbook.html).\nUse `./playground/trace.py` to experiment with the tracing filters and understand how it works.\n\n#### Trace xonsh in the current directory\n\n```xsh\nmkdir -p ~/git/ && cd ~/git/\ngit clone git+https://github.com/xonsh/xonsh\ncd xonsh\nxunter --no-rc -c '1+1' ++cwd ++filter 'Q(filename_has=\"procs/\")' ++output /tmp/out.xun\n# Trace ./xonsh\n# In another terminal:\ntail -f /tmp/out.xun\n```\n\n#### Find function calls\n\n```xsh\nxunter --no-rc -c 'echo 1' ++filter 'Q(filename_has=\"specs.py\")' ++output /tmp/specs.xun\ncat /tmp/specs.xun | grep run_subproc\n# [...]/site-packages/xonsh/procs/specs.py:910:run_subproc \n# <= xonsh/built_ins.py:206:subproc_captured_hiddenobject \n# <= <string>:1:<module> <= xonsh/codecache.py:64:run_compiled_code \n# <= xonsh/codecache.py:218:run_code_with_cache\n# <= xonsh/main.py:519:main_xonsh \n# <= xonsh/main.py:470:main \n# <= xunter/xunter:91:<module>\n# - time_sec=[0.1505]\n\n# Don't forget about xonsh`s awesome macro call:\nxunter --no-rc -c 'echo 1' ++printer call ++filter! Q(filename_has=\"specs.py\"),Q(function=\"run_subproc\")\n```\n\n#### Filter code from prompt-toolkit and unwanted libs\n\n```xsh\n# These `filename` filters will be applied to the code that executed at the end.\n# i.e. `filename=\"a.py\"` will filter `a.py:func <= b.py:func <= c.py:func`\n# but `c.py:func <= a.py:func <= b.py:func` case (`a.py` in the middle) wont be filtered.\nfilters = [\n '~Q(filename_has=\"prompt_toolkit/\")',\n '~Q(filename_has=\"prompt/\")',\n '~Q(filename_has=\"ptk_shell/\")',\n '~Q(filename_has=\"pygments\")',\n \n '~Q(filename_has=\"_distutils_hack\")',\n '~Q(filename_has=\"lazyasd\")',\n '~Q(filename_has=\"environ\")',\n '~Q(filename_has=\"layout\")',\n]\n\nxunter --no-rc ++filter @(','.join(filters)) ++output /tmp/1.xun\n# Run in another terminal to monitor the activity:\ntail -f /tmp/1.xun # | grep -i func\n```\n\n#### Time profiling\n\n```xsh\nxunter --no-rc -c 'echo 1' ++time-sec-gt 0.1 ++depth-lt 2\n# ... - time_sec=[1.3710]\n```\n\n#### Convert log to table\n\n```python\nxunter --no-rc -c \"2+2\" ++depth-lt 10 ++printer stack ++output /tmp/22.xun\nxunter2excel /tmp/22.xun\n```\n\n## Known issues\n\nIf you see the unexpected exceptions try to install xonsh from the main branch first.\n\n## See also\n* [xonsh-cheatsheet](https://github.com/anki-code/xonsh-cheatsheet)\n* [xonsh-install](https://github.com/anki-code/xonsh-install)\n* [How to debug xonsh interactively in IDE PyCharm](https://github.com/xonsh/xonsh/issues/3090#issuecomment-2068043223)\n* By putting `import ipdb; ipdb.set_trace()` into any place of code you can investigate the environment interactively.\n* xonsh builtin [`trace`](https://xon.sh/aliases.html#trace)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Profiling for the xonsh shell based on hunter.",
"version": "0.2.3",
"project_urls": {
"Code": "https://github.com/anki-code/xunter",
"Documentation": "https://github.com/anki-code/xunter/blob/master/README.md",
"Homepage": "https://github.com/anki-code/xunter",
"Issue tracker": "https://github.com/anki-code/xunter/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d1fe82179e19cdb4db882b0f2043edbb4b63a79f62801f12133f2640633237f9",
"md5": "ac83aa2a11a42ab2a3539a353163656f",
"sha256": "89fd28d7fe39b02b3477bbb10ecf40cf0d91d6130334959a4994e79b2d244fae"
},
"downloads": -1,
"filename": "xunter-0.2.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ac83aa2a11a42ab2a3539a353163656f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7850,
"upload_time": "2024-05-04T02:53:49",
"upload_time_iso_8601": "2024-05-04T02:53:49.523921Z",
"url": "https://files.pythonhosted.org/packages/d1/fe/82179e19cdb4db882b0f2043edbb4b63a79f62801f12133f2640633237f9/xunter-0.2.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "edb0bf70dbf24bf1ed1efc36e2222e2a5be6f2bafc90db4cd23dd2bff9d8989d",
"md5": "03f8cdeec0296866cf730c5dfe0ad419",
"sha256": "6f4a926104ea1a5e26b00d3bdf3cff6dbd8e1bb38cd0cc2d0ac975eec06aa091"
},
"downloads": -1,
"filename": "xunter-0.2.3.tar.gz",
"has_sig": false,
"md5_digest": "03f8cdeec0296866cf730c5dfe0ad419",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 7244,
"upload_time": "2024-05-04T02:53:51",
"upload_time_iso_8601": "2024-05-04T02:53:51.130245Z",
"url": "https://files.pythonhosted.org/packages/ed/b0/bf70dbf24bf1ed1efc36e2222e2a5be6f2bafc90db4cd23dd2bff9d8989d/xunter-0.2.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-04 02:53:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "anki-code",
"github_project": "xunter",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "xunter"
}