{"id":13493102,"url":"https://github.com/psf/pyperf","last_synced_at":"2025-12-11T21:02:32.844Z","repository":{"id":37788449,"uuid":"60179028","full_name":"psf/pyperf","owner":"psf","description":"Toolkit to run Python benchmarks","archived":false,"fork":false,"pushed_at":"2025-03-04T13:45:08.000Z","size":1886,"stargazers_count":843,"open_issues_count":32,"forks_count":81,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-04-06T06:17:15.105Z","etag":null,"topics":["benchmarking","python"],"latest_commit_sha":null,"homepage":"http://pyperf.readthedocs.io/","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/psf.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2016-06-01T13:25:17.000Z","updated_at":"2025-03-31T14:44:30.000Z","dependencies_parsed_at":"2023-02-08T19:00:31.051Z","dependency_job_id":"fc79b4f1-7919-4939-ad86-021ebe28c1ec","html_url":"https://github.com/psf/pyperf","commit_stats":{"total_commits":1187,"total_committers":34,"mean_commits":"34.911764705882355","dds":"0.20893007582139844","last_synced_commit":"3f54b5de86402a996b59f82ccf81b289de251dc4"},"previous_names":["vstinner/perf"],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psf%2Fpyperf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psf%2Fpyperf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psf%2Fpyperf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psf%2Fpyperf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psf","download_url":"https://codeload.github.com/psf/pyperf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248557847,"owners_count":21124165,"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":["benchmarking","python"],"created_at":"2024-07-31T19:01:12.222Z","updated_at":"2025-12-11T21:02:27.502Z","avatar_url":"https://github.com/psf.png","language":"Python","readme":"******\npyperf\n******\n\n.. image:: https://img.shields.io/pypi/v/pyperf.svg\n   :alt: Latest release on the Python Cheeseshop (PyPI)\n   :target: https://pypi.python.org/pypi/pyperf\n\n.. image:: https://github.com/psf/pyperf/actions/workflows/build.yml/badge.svg\n   :alt: Build status of pyperf on GitHub Actions\n   :target: https://github.com/psf/pyperf/actions\n\nThe Python ``pyperf`` module is a toolkit to write, run and analyze benchmarks.\n\nFeatures\n========\n\n* Simple API to run reliable benchmarks\n* Automatically calibrate a benchmark for a time budget.\n* Spawn multiple worker processes.\n* Compute the mean and standard deviation.\n* Detect if a benchmark result seems unstable.\n* JSON format to store benchmark results.\n* Support multiple units: seconds, bytes and integer.\n\n\nUsage\n=====\n\nTo `run a benchmark`_ use the ``pyperf timeit`` command (result written into\n``bench.json``)::\n\n    $ python3 -m pyperf timeit '[1,2]*1000' -o bench.json\n    .....................\n    Mean +- std dev: 4.22 us +- 0.08 us\n\nOr write a benchmark script ``bench.py``:\n\n.. code:: python\n\n    #!/usr/bin/env python3\n    import pyperf\n\n    runner = pyperf.Runner()\n    runner.timeit(name=\"sort a sorted list\",\n                  stmt=\"sorted(s, key=f)\",\n                  setup=\"f = lambda x: x; s = list(range(1000))\")\n\nSee `the API docs`_ for full details on the ``timeit`` function and the\n``Runner`` class. To run the script and dump the results into a file named\n``bench.json``::\n\n    $ python3 bench.py -o bench.json\n\nTo `analyze benchmark results`_ use the ``pyperf stats`` command::\n\n    $ python3 -m pyperf stats telco.json\n    Total duration: 29.2 sec\n    Start date: 2016-10-21 03:14:19\n    End date: 2016-10-21 03:14:53\n    Raw value minimum: 177 ms\n    Raw value maximum: 183 ms\n\n    Number of calibration run: 1\n    Number of run with values: 40\n    Total number of run: 41\n\n    Number of warmup per run: 1\n    Number of value per run: 3\n    Loop iterations per value: 8\n    Total number of values: 120\n\n    Minimum:         22.1 ms\n    Median +- MAD:   22.5 ms +- 0.1 ms\n    Mean +- std dev: 22.5 ms +- 0.2 ms\n    Maximum:         22.9 ms\n\n      0th percentile: 22.1 ms (-2% of the mean) -- minimum\n      5th percentile: 22.3 ms (-1% of the mean)\n     25th percentile: 22.4 ms (-1% of the mean) -- Q1\n     50th percentile: 22.5 ms (-0% of the mean) -- median\n     75th percentile: 22.7 ms (+1% of the mean) -- Q3\n     95th percentile: 22.9 ms (+2% of the mean)\n    100th percentile: 22.9 ms (+2% of the mean) -- maximum\n\n    Number of outlier (out of 22.0 ms..23.0 ms): 0\n\n\nThere's also:\n\n* ``pyperf compare_to`` command tests if a difference is\n  significant. It supports comparison between multiple benchmark suites (made\n  of multiple benchmarks)\n  ::\n\n    $ python3 -m pyperf compare_to --table mult_list_py36.json mult_list_py37.json mult_list_py38.json\n    +----------------+----------------+-----------------------+-----------------------+\n    | Benchmark      | mult_list_py36 | mult_list_py37        | mult_list_py38        |\n    +================+================+=======================+=======================+\n    | [1]*1000       | 2.13 us        | 2.09 us: 1.02x faster | not significant       |\n    +----------------+----------------+-----------------------+-----------------------+\n    | [1,2]*1000     | 3.70 us        | 5.28 us: 1.42x slower | 3.18 us: 1.16x faster |\n    +----------------+----------------+-----------------------+-----------------------+\n    | [1,2,3]*1000   | 4.61 us        | 6.05 us: 1.31x slower | 4.17 us: 1.11x faster |\n    +----------------+----------------+-----------------------+-----------------------+\n    | Geometric mean | (ref)          | 1.22x slower          | 1.09x faster          |\n    +----------------+----------------+-----------------------+-----------------------+\n\n* ``pyperf system tune`` command to tune your system to run stable benchmarks.\n* Automatically collect metadata on the computer and the benchmark:\n  use the ``pyperf metadata`` command to display them, or the\n  ``pyperf collect_metadata`` command to manually collect them.\n* ``--track-memory`` and ``--tracemalloc`` options to track\n  the memory usage of a benchmark.\n\n\nQuick Links\n===========\n\n* `pyperf documentation\n  \u003chttps://pyperf.readthedocs.io/\u003e`_\n* `pyperf project homepage at GitHub\n  \u003chttps://github.com/psf/pyperf\u003e`_ (code, bugs)\n* `Download latest pyperf release at the Python Cheeseshop (PyPI)\n  \u003chttps://pypi.python.org/pypi/pyperf\u003e`_\n\nCommand to install pyperf on Python 3::\n\n    python3 -m pip install pyperf\n\npyperf requires Python 3.7 or newer.\n\nPython 2.7 users can use pyperf 1.7.1 which is the last version compatible with\nPython 2.7.\n\npyperf is distributed under the MIT license.\n\nThe pyperf project is covered by the `PSF Code of Conduct\n\u003chttps://www.python.org/psf/codeofconduct/\u003e`_.\n\n.. _run a benchmark: https://pyperf.readthedocs.io/en/latest/run_benchmark.html\n.. _the API docs: http://pyperf.readthedocs.io/en/latest/api.html#Runner.timeit\n.. _analyze benchmark results: https://pyperf.readthedocs.io/en/latest/analyze.html\n","funding_links":[],"categories":["Python","Benchmarking","Python 程序"],"sub_categories":["Typehint","网络服务_其他"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsf%2Fpyperf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsf%2Fpyperf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsf%2Fpyperf/lists"}