# orca.estimate

> A module of morca's API.

How long runs of a pipeline would take, from how long its recent runs took.

A pipeline's last `SAMPLE` succeeded runs give its seconds per partition:
their running time (`started` to `ended`, not the wait in the queue) over
the partitions they ran. A backfill of `runs` runs over `keys` partitions
takes waves of `max_runs` runs at once, each about as long as a run of
its size; one run over them all takes them one after another.

## Structs

### `Pace`

```mojo
struct Pace
```

A pipeline's seconds per partition, and the runs that says it.

Implements: `Copyable`, `Movable`

Fields:

- `per_key: Float64`: -1 when no run has succeeded yet.
- `runs: Int`

#### `known`

```mojo
def known(self) -> Bool
```

#### `backfill`

```mojo
def backfill(self, keys: Int, runs: Int, max_runs: Int) -> Int
```

Seconds for `runs` runs over `keys` partitions, `max_runs` at once; -1 if not known.

#### `one_run`

```mojo
def one_run(self, keys: Int) -> Int
```

Seconds for one run over `keys` partitions; -1 if not known.

## Functions

### `pace`

```mojo
def pace(mut db: State, pipeline: String) -> Pace
```

`pipeline`'s pace over its last `SAMPLE` succeeded runs.

### `per_key_text`

```mojo
def per_key_text(p: Pace, unit: String) -> String
```

"95 s a day over its last 20 runs".

### `estimate_text`

```mojo
def estimate_text(p: Pace, seconds: Int, unit: String, at_once: Int) -> String
```

"About 2h 10m, 1 run at once (95 s a day over its last 20 runs)." or why there's no estimate.

## Aliases

### `SAMPLE`

```mojo
comptime SAMPLE = 20
```

The most recent succeeded runs the estimate is taken from.
