# Code Performance Events

Machine 1 already has a speed loss built in. Its standard rate is **3.75 lbs/min**, but the simulator feeds it at only about **3.25 lbs/min**, which matches the scheduled rate you configured in [Configure Production Rates](../01-base-configuration/3-configure-item-rates.md). Expected infeed is always based on the **standard** rate, so every minute Machine 1 runs, Kanoa counts the gap between expected and actual infeed as lost time.

```text
Runtime:           60 min
Expected infeed:   60 × 3.75 = 225 lbs
Actual infeed:     60 × 3.25 = 195 lbs
Missing infeed:    30 lbs  →  30 ÷ 3.75 = 8 lost minutes
```

Speed loss is measured on the **infeed**, because it is lost process time, not lost output. Time the machine was stopped is downtime and is handled by state events, not performance events.

:::action[Code the lost minutes]

1. Navigate to **Ops → Operations → Performance Events**.
2. Select **Machine 1** and today's date range, then run the report.

Review the rows in the upper table. Each one shows the runtime, expected and actual infeed, and the **lost minutes** Kanoa calculated, with any uncoded time still open.
<br/>
3. Select a row and click the add button.
5. Choose `Tool Wear`, enter part of the lost minutes (for example, half), and add a note such as `Feed reduced after insert change was postponed`.
6. Save, then add a second event for the remaining minutes using `Material Hardness Variation`.
7. Confirm the row no longer shows uncoded lost time.

:::

Kanoa doesn't create the loss when you code it. The loss already exists in the OEE performance number. Coding only explains it, so the same minutes can be split across several reasons when more than one thing slowed the line.

:::tip
Code performance events while the details are fresh, ideally at the end of each shift. Reasons can also be written by script with `system.kanoa.event.addPerformanceEvent` when a machine or supervisory system already reports why it slowed down.
:::

:::action[Chart performance reasons]

1. Open the dashboard you built in [Build a Dashboard](../06-analytics/1-dashboard-build.md), or create a new one named `Machining Performance`.
2. Add the **performanceReasonPieChart** widget and the **performanceReasonTable** widget (from `kanoa/core/dbp/widgets/analytics`).
3. Select Machine 1 and today in the dashboard's asset and date range selectors (if you created a new dashboard, add these selectors first, as in Build a Dashboard), and confirm your coded minutes appear by reason.

:::
