Skip to content

Commit

Permalink
chore: cleanup docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Pog3k committed Jan 31, 2025
1 parent 1b46919 commit 1174e4c
Showing 1 changed file with 40 additions and 36 deletions.
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

0 comments on commit 1174e4c

Please sign in to comment.