{"id":18274981,"url":"https://github.com/trevor-vincent/simple-python-flamegraph-profiler","last_synced_at":"2025-08-24T06:19:17.094Z","repository":{"id":250105666,"uuid":"833484198","full_name":"trevor-vincent/simple-python-flamegraph-profiler","owner":"trevor-vincent","description":"Simple sampling python profiler with Flamegraph output","archived":false,"fork":false,"pushed_at":"2024-07-25T07:46:02.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-14T22:25:18.166Z","etag":null,"topics":["flamegraph","profiler"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trevor-vincent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-25T06:38:34.000Z","updated_at":"2024-07-25T15:38:53.000Z","dependencies_parsed_at":"2024-07-25T07:55:42.752Z","dependency_job_id":"1129ed7c-7dde-479c-af0e-9b9184df0107","html_url":"https://github.com/trevor-vincent/simple-python-flamegraph-profiler","commit_stats":null,"previous_names":["trevor-vincent/simple-python-flamegraph-profiler"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevor-vincent%2Fsimple-python-flamegraph-profiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevor-vincent%2Fsimple-python-flamegraph-profiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevor-vincent%2Fsimple-python-flamegraph-profiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trevor-vincent%2Fsimple-python-flamegraph-profiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trevor-vincent","download_url":"https://codeload.github.com/trevor-vincent/simple-python-flamegraph-profiler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247974595,"owners_count":21026742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flamegraph","profiler"],"created_at":"2024-11-05T12:11:27.866Z","updated_at":"2025-04-09T03:44:49.363Z","avatar_url":"https://github.com/trevor-vincent.png","language":"Python","readme":"\n# Simple Python Sampling Profiler with FlameGraph Output\n\nThis repository contains a simple sampling-based profiler for Python programs. It periodically collects stack traces to analyze the performance of the code. The output can be directly converted to a FlameGraph using Brendan Greggs Flamegraph perl script. Don't be fooled by the simplicity, it is still very accurate and useful.\n\n## Installation\n\n1. Nothing to install. Python 3 is required. \n\n## Usage\n\n### Example\n\n```python\nfrom profiler import Sampler\n\ndef some_function():\n    b = 0    \n    for i in range(100000000):\n        b += 1\n\ndef another_function():\n    c = 0\n    for i in range(100000000):\n        c += 1\n\ndef main():\n    # Initialize the sampler\n    sampler = Sampler()\n\n    # Start the sampler\n    sampler.start()\n\n    # Code to profile\n    some_function()\n    another_function()\n\n    # Output the collected statistics to a file\n    sampler.output_stats(\"example.stacks\")\n    \n    # Stop the sampler\n    sampler.stop()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Output\n\nThe profiler will generate a `.stacks` file containing the profiling results that is directly readable by Brendan Gregg's Flamegraph program.\n\n### Converting the stacks file to a FlameGraph\n\nTo convert the profiling output to a FlameGraph, follow these steps:\n\n1. Ensure you have `FlameGraph` tools installed. If not, clone the repository:\n    ```bash\n    git clone https://github.com/brendangregg/FlameGraph.git\n    ```\n\n2. Use the `flamegraph.pl` script to generate the FlameGraph from the `.stacks` file:\n    ```bash\n    ./FlameGraph/flamegraph.pl example.stacks \u003e example.svg\n    ```\n\n3. Open the generated [example.svg](example.svg) file in a web browser to visualize the FlameGraph.\n\n## License\n\nThis project is licensed under the MIT License.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevor-vincent%2Fsimple-python-flamegraph-profiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrevor-vincent%2Fsimple-python-flamegraph-profiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrevor-vincent%2Fsimple-python-flamegraph-profiler/lists"}