Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup docs #530

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 40 additions & 36 deletions docs/advanced_usage/profiling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ The `@profile` decorator can be used in two ways:
- **Specifying** a file path**: Generates an uncompressed result file with the specified file path.
- **Compressed output**: When `compress=True` is set, the output file is compressed into a `.cvf` format.

Example Usage
-------------
Decorator Example
-----------------

```python
from pykiso.profiling import profile
.. code:: python

@profile
def test_method():
pass
from pykiso.profiling import profile

@profile("result.json")
def test_method():
pass
@profile
def test_method():
pass

@profile("result.json")
def test_method():
pass


@profile(compress=True)
def test_method():
pass

@profile(compress=True)
def test_method():
pass
```

Using the `profile_manager`
===========================
Expand All @@ -43,16 +44,16 @@ If you want to profile a section of your code, you can use the `profile_manager`
In this case, you need to specify the file path and whether to compress the output file.
Everything inside the context manager will be profiled.

Example Usage
-------------
Context Manager Example
-----------------------

```python
from pykiso.profiling import profile_manager
.. code:: python

def test_method():
with profile_manager("testrun2.json", compress=False):
time.sleep(1)
```
from pykiso.profiling import profile_manager

def test_method():
with profile_manager("testrun2.json", compress=False):
time.sleep(1)

Using the get_tracer() function
===============================
Expand All @@ -61,18 +62,20 @@ If you want to be in full control of the profiling process, you can use the `get
It will return the viztracer.Tracer object, which you can use to start and stop the profiling process.
To create a result file, you need to call the save() method on the Tracer object.

Example Usage
-------------
```python
from pykiso.profiling import get_tracer
Raw Viztracer Example
---------------------

.. code:: python

from pykiso.profiling import get_tracer

def test_method():
tracer = get_tracer()
tracer.start()
time.sleep(1)
tracer.stop()
tracer.save("testrun3.json")

def test_method():
tracer = get_tracer()
tracer.start()
time.sleep(1)
tracer.stop()
tracer.save("testrun3.json")
```

Visualizing Profiling Results
=============================
Expand All @@ -82,9 +85,10 @@ To analyze the generated result file, use the `vizviewer` command-line tool. Thi
Running `vizviewer`
-------------------

```bash
vizviewer <result_filename>.json
```
.. code:: bash

vizviewer <result_filename>.json


Benefits of Profiling
=====================
Expand Down