> ## 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.

# Performance Metrics • Rust AI Agent SDK

> PerformanceMetrics: Performance metrics from an evaluation.

# PerformanceMetrics

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

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

Performance metrics from an evaluation.

## Fields

| Name                | Type                     | Description                         |
| ------------------- | ------------------------ | ----------------------------------- |
| `duration`          | `Duration`               | Total duration                      |
| `ttft`              | `Option&lt;Duration&gt;` | Time to first token (if applicable) |
| `tokens_per_second` | `Option&lt;f64&gt;`      | Tokens per second                   |
| `memory_bytes`      | `Option&lt;usize&gt;`    | Memory usage in bytes               |
| `input_tokens`      | `Option&lt;usize&gt;`    | Input tokens                        |
| `output_tokens`     | `Option&lt;usize&gt;`    | Output tokens                       |

## Methods

### `new`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn new(duration: Duration) -> Self
```

Create new metrics with duration.

**Parameters:**

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

### `with_ttft`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_ttft(mut self, ttft: Duration) -> Self
```

Set TTFT.

**Parameters:**

| Name   | Type       |
| ------ | ---------- |
| `ttft` | `Duration` |

### `with_tokens_per_second`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_tokens_per_second(mut self, tps: f64) -> Self
```

Set tokens per second.

**Parameters:**

| Name  | Type  |
| ----- | ----- |
| `tps` | `f64` |

### `with_tokens`

```rust theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
fn with_tokens(mut self, input: usize, output: usize) -> Self
```

Set token counts.

**Parameters:**

| Name     | Type    |
| -------- | ------- |
| `input`  | `usize` |
| `output` | `usize` |

## Source

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