{"id":13398309,"url":"https://github.com/what-studio/profiling","last_synced_at":"2025-12-30T08:05:40.335Z","repository":{"id":20341770,"uuid":"23616394","full_name":"what-studio/profiling","owner":"what-studio","description":"Was an interactive continuous Python profiler.","archived":true,"fork":false,"pushed_at":"2020-08-24T01:31:58.000Z","size":633,"stargazers_count":2964,"open_issues_count":17,"forks_count":115,"subscribers_count":74,"default_branch":"master","last_synced_at":"2024-04-26T15:43:24.892Z","etag":null,"topics":["debug","live-profiling","profiling","python","statistical-profiling"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/what-studio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-03T10:35:57.000Z","updated_at":"2024-04-20T09:13:27.000Z","dependencies_parsed_at":"2022-08-28T17:52:01.002Z","dependency_job_id":null,"html_url":"https://github.com/what-studio/profiling","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/what-studio%2Fprofiling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/what-studio%2Fprofiling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/what-studio%2Fprofiling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/what-studio%2Fprofiling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/what-studio","download_url":"https://codeload.github.com/what-studio/profiling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243511660,"owners_count":20302595,"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":["debug","live-profiling","profiling","python","statistical-profiling"],"created_at":"2024-07-30T19:00:22.430Z","updated_at":"2025-12-18T01:04:46.827Z","avatar_url":"https://github.com/what-studio.png","language":"Python","readme":"☠ This project is not maintained anymore. We highly recommend switching to\n[py-spy](https://github.com/benfred/py-spy) which provides better performance\nand usability.\n\n---\n\nProfiling\n=========\n\nThe profiling package is an interactive continuous Python profiler.  It is\ninspired from [Unity 3D] profiler.  This package provides these features:\n\n- Profiling statistics keep the frame stack.\n- An interactive TUI profiling statistics viewer.\n- Provides both of statistical and deterministic profiling.\n- Utilities for remote profiling.\n- Thread or greenlet aware CPU timer.\n- Supports Python 2.7, 3.3, 3.4 and 3.5.\n- Currently supports only Linux.\n\n[![Build Status](https://img.shields.io/travis/what-studio/profiling.svg)](https://travis-ci.org/what-studio/profiling)\n[![Coverage Status](https://img.shields.io/coveralls/what-studio/profiling.svg)](https://coveralls.io/r/what-studio/profiling)\n\n[Unity 3D]: http://unity3d.com/\n\nInstallation\n------------\n\nInstall the latest release via PyPI:\n\n```sh\n$ pip install profiling\n```\n\nProfiling\n---------\n\nTo profile a single program, simply run the `profiling` command:\n\n```sh\n$ profiling your-program.py\n```\n\nThen an interactive viewer will be executed:\n\n![](screenshots/tracing.png)\n\nIf your program uses greenlets, choose `greenlet` timer:\n\n```sh\n$ profiling --timer=greenlet your-program.py\n```\n\nWith `--dump` option, it saves the profiling result to a file.  You can\nbrowse the saved result by using the `view` subcommand:\n\n```sh\n$ profiling --dump=your-program.prf your-program.py\n$ profiling view your-program.prf\n```\n\nIf your script reads ``sys.argv``, append your arguments after ``--``.\nIt isolates your arguments from the ``profiling`` command:\n\n```sh\n$ profiling your-program.py -- --your-flag --your-param=42\n```\n\nLive Profiling\n--------------\n\nIf your program has a long life time like a web server, a profiling result\nat the end of program is not helpful enough.  Probably you need a continuous\nprofiler.  It can be achived by the `live-profile` subcommand:\n\n```sh\n$ profiling live-profile webserver.py\n```\n\nSee a demo:\n\n[![asciicast](https://asciinema.org/a/25394.png)](https://asciinema.org/a/25394)\n\nThere's a live-profiling server also.  The server doesn't profile the\nprogram at ordinary times.  But when a client connects to the server, it\nstarts to profile and reports the results to the all connected clients.\n\nStart a profling server by the `remote-profile` subcommand:\n\n```sh\n$ profiling remote-profile webserver.py --bind 127.0.0.1:8912\n```\n\nAnd also run a client for the server by the `view` subcommand:\n\n```sh\n$ profiling view 127.0.0.1:8912\n```\n\nStatistical Profiling\n---------------------\n\n`TracingProfiler`, the default profiler, implements a deterministic profiler\nfor deep call graph.  Of course, it has heavy overhead.  The overhead can\npollute your profiling result or can make your application to be slow.\n\nIn contrast, `SamplingProfiler` implements a statistical profiler.  Like other\nstatistical profilers, it also has only very cheap overhead.  When you profile\nyou can choose it by just `--sampling` (shortly `-S`) option:\n\n```sh\n$ profiling live-profile -S webserver.py\n                         ^^\n```\n\n![](screenshots/sampling.png)\n\nTimeit then Profiling\n---------------------\n\nDo you use `timeit` to check the performance of your code?\n\n```sh\n$ python -m timeit -s 'from trueskill import *' 'rate_1vs1(Rating(), Rating())'\n1000 loops, best of 3: 722 usec per loop\n```\n\nIf you want to profile the checked code, simply use the `timeit` subcommand:\n\n```sh\n$ profiling timeit -s 'from trueskill import *' 'rate_1vs1(Rating(), Rating())'\n  ^^^^^^^^^\n```\n\nProfiling from Code\n-------------------\n\nYou can also profile your program by ``profiling.tracing.TracingProfiler`` or\n``profiling.sampling.SamplingProfiler`` directly:\n\n```python\nfrom profiling.tracing import TracingProfiler\n\n# profile your program.\nprofiler = TracingProfiler()\nprofiler.start()\n...  # run your program.\nprofiler.stop()\n\n# or using context manager.\nwith profiler:\n    ...  # run your program.\n\n# view and interact with the result.\nprofiler.run_viewer()\n# or save profile data to file\nprofiler.dump('path/to/file')\n```\n\nViewer Key Bindings\n-------------------\n\n- \u003ctt\u003eq\u003c/tt\u003e - Quit.\n- \u003ctt\u003espace\u003c/tt\u003e - Pause/Resume.\n- \u003ctt\u003e\\\\\u003c/tt\u003e - Toggle layout between NESTED and FLAT.\n- \u003ctt\u003e↑\u003c/tt\u003e and \u003ctt\u003e↓\u003c/tt\u003e - Navigate frames.\n- \u003ctt\u003e→\u003c/tt\u003e - Expand the frame.\n- \u003ctt\u003e←\u003c/tt\u003e - Fold the frame.\n- \u003ctt\u003e\u003e\u003c/tt\u003e - Go to the hotspot.\n- \u003ctt\u003eesc\u003c/tt\u003e - Defocus.\n- \u003ctt\u003e[\u003c/tt\u003e and \u003ctt\u003e]\u003c/tt\u003e - Change sorting column.\n\nColumns\n-------\n\n### Common\n\n- `FUNCTION`\n  1. The function name with the code location.\n     (e.g. `my_func (my_code.py:42)`, `my_func (my_module:42)`)\n  1. Only the location without line number.  (e.g. `my_code.py`, `my_module`)\n\n### Tracing Profiler\n\n- `CALLS` - Total call count of the function.\n- `OWN` (Exclusive Time) - Total spent time in the function excluding sub\n                           calls.\n- `/CALL` after `OWN` - Exclusive time per call.\n- `%` after `OWN` - Exclusive time per total spent time.\n- `DEEP` (Inclusive Time) - Total spent time in the function.\n- `/CALL` after `DEEP` - Inclusive time per call.\n- `%` after `DEEP` - Inclusive time per total spent time.\n\n### Sampling Profiler\n\n- `OWN` (Exclusive Samples) - Number of samples which are collected during the\n                              direct execution of the function.\n- `%` after `OWN` - Exclusive samples per number of the total samples.\n- `DEEP` (Inclusive Samples) - Number of samples which are collected during the\n                               excution of the function.\n- `%` after `DEEP` - Inclusive samples per number of the total samples.\n\nTesting\n-------\n\nThere are some additional requirements to run the test code, which can be\ninstalled by running the following command.\n\n```sh\n$ pip install $(python test/fit_requirements.py test/requirements.txt)\n```\n\nThen you should be able to run `pytest`.\n\n```sh\n$ pytest -v\n```\n\nThanks to\n---------\n\n- [Seungmyeong Yang](https://github.com/sequoiayang)\n  who suggested this project.\n- [Pavel](https://github.com/htch)\n  who inspired to implement ``-m`` option.\n\nLicensing\n---------\n\nWritten by [Heungsub Lee] at [What! Studio] in [Nexon], and\ndistributed under the [BSD 3-Clause] license.\n\n[Heungsub Lee]: http://subl.ee/\n[What! Studio]: https://github.com/what-studio\n[Nexon]: http://nexon.com/\n[BSD 3-Clause]: http://opensource.org/licenses/BSD-3-Clause\n","funding_links":[],"categories":["Debugging Tools","Python","资源列表","Awesome Python"],"sub_categories":["调试工具","Debugging Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhat-studio%2Fprofiling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhat-studio%2Fprofiling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhat-studio%2Fprofiling/lists"}