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.4.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.4-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyros_performance-0.1.4.tar.gz
Algorithm Hash digest
SHA256 e49e14212d9cd1c2958e17485ef0134c288ebcec099671aa9c4bb0540c53725a
MD5 7da38004f40ad80af67a2d646df4f8ef
BLAKE2b-256 1d6189db0b790092386624ee065f151b33e4e5bf6856f12017ed56cbcb2e5c76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyros_performance-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0eeb0722fec0ad61840e5d6ce3980a368afd85549f5d7bb625ab0d951e2c68a4
MD5 e396d68e09761b23366d5d9266be510d
BLAKE2b-256 690ffa2894feec8213df813568b352d0a71f32bbbf5d28d69f1663e0b25bac63

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