Skip to main content

ROS2-friendly function performance profiler

Project description

Pyros Performance

A high-performance Python library for benchmarking and profiling your code. it can be used for both ros2 functions and non-ros2 functions. project is part of the pyros library.

Installation

pip install pyros-performance

Quick Start

from pyros_performance import profiler, render
import threading

@profiler()
def sum_numbers(*args):
    total = 0
    for _ in range(200000):
        for v in args:
            total += v
        total *= 1
    return total


@profiler()
def heavy_math():
    x = 0
    for i in range(300000):
        x += i * 0.5
        x = x % 100000
    return x

if __name__ == "__main__":

    # start dashboard thread
    t = threading.Thread(target=render, daemon=True)
    t.start()

    # simulate workload
    while True:
        sum_numbers(1, 2, 3)
        heavy_math()
        time.sleep(0.2)

Example Output

============================================================
           ROS2 LIGHTWEIGHT PROFILER
============================================================

SYSTEM
------------------------------------------------------------
CPU Total: 6.9%
Memory RSS: 13.31 MB

Per-Core CPU:
Core 00:                      2.0%
Core 01:                      4.0%
Core 02: ██                   11.8%
Core 03:                      2.0%
Core 04: █                    6.1%
Core 05: ██                   13.7%
Core 06: ██████               31.4%
Core 07:                      0.0%
Core 08: █                    6.0%
Core 09: █                    6.0%
Core 10:                      0.0%
Core 11:                      4.0%
Core 12:                      4.0%
Core 13: █                    5.9%
Core 14: █                    6.0%
Core 15:                      3.9%

FUNCTIONS
------------------------------------------------------------

sum_numbers
  calls     : 5
  wall avg  : 15.630 ms
  cpu avg   : 16.000 ms
  last wall : 14.789 ms
  last cpu  : 20.000 ms

heavy_math
  calls     : 5
  wall avg  : 13.479 ms
  cpu avg   : 12.000 ms
  last wall : 12.910 ms
  last cpu  : 10.000 ms

============================================================

Features

  • Easy benchmarking - Simple API for measuring execution time
  • Memory profiling - Track memory usage during execution
  • Performance reports - Generate detailed performance metrics
  • Low overhead - Minimal impact on your code performance

Documentation

For detailed documentation, visit GitHub.

Requirements

  • Python 3.8+

License

MIT

Contributing

Contributions welcome! Please submit pull requests or issues on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyros_performance-0.1.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyros_performance-0.1.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file pyros_performance-0.1.3.tar.gz.

File metadata

  • Download URL: pyros_performance-0.1.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for pyros_performance-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5a5d763baa9c8ede4ea075cb4b47a852e9330c6752c7046ef2d300f237cd05fc
MD5 86d7565a67d627223c177857a181ff1b
BLAKE2b-256 79ec722958c4dc8d1d63890e25c85e059799582ef66cc2737dbf3851d7b1da39

See more details on using hashes here.

File details

Details for the file pyros_performance-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pyros_performance-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 34f7f8c3dabc87c608b7105352b9a1d7212d68bf501dc16c7488e441e91cdc3f
MD5 e8d119a43144a00acac4d9d8d1d0d36b
BLAKE2b-256 b6f0236e23352114646984c5798b1744fcabcbe9d3cb2f759a15affc152a55de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page