> For the complete documentation index, see [llms.txt](https://infinitode-docs.gitbook.io/documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitode-docs.gitbook.io/documentation/package-documentation/funcprofiler-package-documentation.md).

# FuncProfiler Package Documentation

## Changelog

* **1.2.0 (Latest)**:
  * Significant performance improvements for both function and line-by-line profiling.
  * Cached function metadata at decoration time to reduce overhead during execution.
  * Optimized line-by-line tracing using code object identity comparison.
  * Implemented buffered logging for shared logs to minimize frequent file I/O.
  * Improved trace accuracy by properly capturing the final line's execution time.
  * Refactored export logic for more efficient report generation.
* **1.1.0**:
  * Added support for 2 new export formats: `yaml` and `toml`.
  * Exports now include more information: peak memory usage, timestamp, arguments, return value, filepath, line number, and docstring.
  * Added `enabled` and `log_level` options to the decorators.
  * Improved export formats for better readability.
* **1.0.2**: Created 2 new export formats: `xml`, `md` for both function profiling and line-by-line profiling.
* **1.0.1**: Updated PYPI project description.
* **1.0.0**: Initial release.

## Installation

You can install FuncProfiler using PyPi, please make sure that you are using Python 3.6 or later before installing FuncProfiler:

```bash
pip install funcprofiler
```

***

## Example Usage

### Function Profiling

```python
from funcprofiler import function_profile

# Exporting as `html` with logging enabled
@function_profile(export_format="html", shared_log=True)
def some_function():
    return "Hello World."

# Call the function
message = some_function()
```

### Line-by-Line Profiling

```python
from funcprofiler import line_by_line_profile

# Logging enabled without exports
@line_by_line_profile(shared_log=True)
def some_complicated_function(n):
    total = 0
    for i in range(n):
        for j in range(i):
            total += (i * j) ** 0.5  # Square root calculation
    return total

# Call the function
total = some_complicated_function(1000)
```

{% hint style="info" %}
**FuncProfiler** can be added to any function using the callable format: `@funcprofiler_function_name(expected_arguments)`.
{% endhint %}
