{"id":5229,"library":"flameprof","title":"Flameprof","description":"Flameprof is a Python library and command-line tool that generates interactive SVG flame graphs from `cProfile` statistics. It visualizes function call hierarchies and their CPU time consumption, offering a compact and understandable alternative to raw `cProfile` output or tools like `gprof2dot`. The current version is 0.4. Releases are sporadic, with major updates occurring infrequently.","status":"active","version":"0.4","language":"python","source_language":"en","source_url":"https://github.com/baverman/flameprof/","tags":["profiling","flamegraph","cprofile","performance","visualization"],"install":[{"cmd":"pip install flameprof","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"note":"Flameprof is primarily used as a command-line tool to process cProfile output files, rather than through direct Python imports for its core functionality.","symbol":"flameprof CLI","correct":"flameprof input.prof > output.svg"}],"quickstart":{"code":"# my_app.py\nimport cProfile\nimport time\n\ndef func_a():\n    time.sleep(0.1)\n\ndef func_b():\n    time.sleep(0.05)\n    func_a()\n\ndef main():\n    for _ in range(3):\n        func_b()\n    func_a()\n\n# Profile the application\nprofile_file = 'my_app.prof'\ncProfile.run('main()', profile_file)\n\n# To generate the flame graph, run in your terminal:\n# flameprof my_app.prof > my_app_flamegraph.svg\n# Then open my_app_flamegraph.svg in a web browser.","lang":"python","description":"First, create a Python script (`my_app.py`) that you wish to profile. Use Python's built-in `cProfile` module to run your application and save the profiling data to a `.prof` file. Then, use the `flameprof` command-line tool to convert this `.prof` file into an interactive SVG flame graph. Open the generated SVG file in a web browser to view the visualization."},"warnings":[{"fix":"Always invoke `flameprof` from your terminal or shell scripts after generating a cProfile output file.","message":"Flameprof is primarily a command-line utility. While it is a Python package, its main functionality is exposed via the `flameprof` executable after installation, not typically through direct Python `import` statements for generating flame graphs.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your profiling data is in the `cProfile` format. If you need to profile other sources, consider converting their output to a compatible format or using different flame graph generators.","message":"The input file for `flameprof` must be a statistics file generated by Python's `cProfile` module (e.g., created with `cProfile.run('my_func()', 'output.prof')` or `python -m cProfile -o output.prof myscript.py`). It does not natively support output from other profiling tools like `perf` or `py-spy` without prior conversion.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If encountering these errors, try simplifying the profiled code or updating to the latest `flameprof` version. For critical debugging, consider alternative profiling visualization tools if the issue persists.","message":"Users have reported instances where `flameprof` can produce 'impossible stacks' or `ZeroDivisionError: float division by zero` when processing certain `cProfile` data, especially with unusual call patterns or highly optimized code.","severity":"gotcha","affected_versions":"0.3, 0.4"}],"env_vars":null,"search_vec":"'0.4':49 'altern':36 'call':24 'command':9 'command-lin':8 'compact':33 'consumpt':30 'cprofil':19,39,60 'cpu':28 'current':46 'flame':16 'flamegraph':59 'flameprof':1,2 'function':23 'generat':13 'gprof2dot':44 'graph':17 'hierarchi':25 'infrequ':57 'interact':14 'librari':6 'like':43 'line':10 'major':54 'occur':56 'offer':31 'output':40 'perform':61 'profil':58 'python':5 'raw':38 'releas':50 'sporad':52 'statist':20 'svg':15 'time':29 'tool':11,42 'understand':35 'updat':55 'version':47 'visual':22,62","created_at":"2026-04-14T01:24:47.313051+00:00","updated_at":"2026-04-17T14:03:21.606406+00:00","problems":{"verify_error":"no import statement found"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.4","cli_name":"flameprof","cli_version":"flameprof.py 0.4","type":"library","homepage":null,"github":"https://github.com/baverman/flameprof","docs":null,"changelog":null,"pypi":"https://pypi.org/project/flameprof/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["observability","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-05","install_tag":null}}