trace-events


Nametrace-events JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/JonathanHiggs/trace_events
SummaryPython event tracing using the Trace Event Format supported by Chromium browsers
upload_time2023-07-05 22:07:01
maintainer
docs_urlNone
authorJonathan Higgs
requires_python>=3.8
licenseMIT
keywords trace tracing event profile profiler
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Trace Events

Python event tracing using the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit)
which is supported by Chromium browsers and other tools

## Installing

Install and update using [pip](https://pypi.org/project/pip/)

## Usage

Add tracing to sections of your code and execute to generate a `json` trace file

```python
import time
from trace_events import Profiler, profile, timeit

@profile
def foo():
    # ... do some work

@profile(category='suspected-slow')
def bar():
    time.sleep(1)

def baz(value):
    with timeit('baz::foo'):
        foo()

    with timeit('baz::bar', value=value):
        bar()

if __name__ == '__main__':
    baz(10)

    Profiler.global_profiler().save_trace('trace.json')
```

Traces are saved `atexit` to a default `trace.json` file, or can be configured with a call to `init_trace`

```python
import trace_events

trace_events.init_trace(
    trace_file_dir='./my-traces',
    trace_file_name='my-trace.json',
    # save_at_exit = True
    # overwrite_trace_files=False,
    # logger=logging.getLogger("trace_events")
)
```

Open up a Chromium browser to [chrome://tracing](chrome://tracing) and load the file to view the trace

![Example image](media/example.png)

More examples in the examples folder

- [Basic Example](examples/basic-example.py)
- [Logging Example](examples/logging-example.py)
- [Tracing Disabled](examples/tracing-disabled.py)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/JonathanHiggs/trace_events",
    "name": "trace-events",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "trace tracing event profile profiler",
    "author": "Jonathan Higgs",
    "author_email": "jonathan.higgs.11@mail.wbs.ac.uk",
    "download_url": "",
    "platform": null,
    "description": "# Trace Events\r\n\r\nPython event tracing using the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/edit)\r\nwhich is supported by Chromium browsers and other tools\r\n\r\n## Installing\r\n\r\nInstall and update using [pip](https://pypi.org/project/pip/)\r\n\r\n## Usage\r\n\r\nAdd tracing to sections of your code and execute to generate a `json` trace file\r\n\r\n```python\r\nimport time\r\nfrom trace_events import Profiler, profile, timeit\r\n\r\n@profile\r\ndef foo():\r\n    # ... do some work\r\n\r\n@profile(category='suspected-slow')\r\ndef bar():\r\n    time.sleep(1)\r\n\r\ndef baz(value):\r\n    with timeit('baz::foo'):\r\n        foo()\r\n\r\n    with timeit('baz::bar', value=value):\r\n        bar()\r\n\r\nif __name__ == '__main__':\r\n    baz(10)\r\n\r\n    Profiler.global_profiler().save_trace('trace.json')\r\n```\r\n\r\nTraces are saved `atexit` to a default `trace.json` file, or can be configured with a call to `init_trace`\r\n\r\n```python\r\nimport trace_events\r\n\r\ntrace_events.init_trace(\r\n    trace_file_dir='./my-traces',\r\n    trace_file_name='my-trace.json',\r\n    # save_at_exit = True\r\n    # overwrite_trace_files=False,\r\n    # logger=logging.getLogger(\"trace_events\")\r\n)\r\n```\r\n\r\nOpen up a Chromium browser to [chrome://tracing](chrome://tracing) and load the file to view the trace\r\n\r\n![Example image](media/example.png)\r\n\r\nMore examples in the examples folder\r\n\r\n- [Basic Example](examples/basic-example.py)\r\n- [Logging Example](examples/logging-example.py)\r\n- [Tracing Disabled](examples/tracing-disabled.py)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python event tracing using the Trace Event Format supported by Chromium browsers",
    "version": "0.1.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/JonathanHiggs/trace_events/issues",
        "Homepage": "https://github.com/JonathanHiggs/trace_events",
        "Source": "https://github.com/JonathanHiggs/trace_events"
    },
    "split_keywords": [
        "trace",
        "tracing",
        "event",
        "profile",
        "profiler"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e136283716214b74b4a6461b2570a741be4d87851c3631b7cd4b05285c2975aa",
                "md5": "8e8f275f4398d0d271e90b769af51064",
                "sha256": "8c31a5a6579745f5ee57c7167de9051ffa8fd1b7d90edf215c0c9f6664cb043b"
            },
            "downloads": -1,
            "filename": "trace_events-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e8f275f4398d0d271e90b769af51064",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12993,
            "upload_time": "2023-07-05T22:07:01",
            "upload_time_iso_8601": "2023-07-05T22:07:01.733886Z",
            "url": "https://files.pythonhosted.org/packages/e1/36/283716214b74b4a6461b2570a741be4d87851c3631b7cd4b05285c2975aa/trace_events-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-05 22:07:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JonathanHiggs",
    "github_project": "trace_events",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "trace-events"
}
        
Elapsed time: 0.08235s