> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Function Stats • Rust AI Agent SDK

> FunctionStats: Statistics for a tracked function.

# FunctionStats

> Defined in the [**telemetry**](../modules/telemetry) module.

<Badge color="orange">Rust AI Agent SDK</Badge>

Statistics for a tracked function.

## Fields

| Name             | Type       | Description        |
| ---------------- | ---------- | ------------------ |
| `name`           | `String`   | Function name      |
| `call_count`     | `usize`    | Number of calls    |
| `total_duration` | `Duration` | Total duration     |
| `min_duration`   | `Duration` | Minimum duration   |
| `max_duration`   | `Duration` | Maximum duration   |
| `last_duration`  | `Duration` | Last call duration |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(name: impl Into<String>) -> Self
```

Create new stats for a function.

**Parameters:**

| Name   | Type                      |
| ------ | ------------------------- |
| `name` | `impl Into&lt;String&gt;` |

### `record`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn record(&mut self, duration: Duration) -> ()
```

Record a call.

**Parameters:**

| Name       | Type       |
| ---------- | ---------- |
| `duration` | `Duration` |

### `average_duration`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn average_duration(&self) -> Duration
```

Get average duration.

### `calls_per_second`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn calls_per_second(&self, elapsed: Duration) -> f64
```

Get calls per second.

**Parameters:**

| Name      | Type       |
| --------- | ---------- |
| `elapsed` | `Duration` |

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-rust/praisonai/src/telemetry/mod.rs#L26">
  `praisonai/src/telemetry/mod.rs` at line 26
</Card>
