tests.Cost
What an interaction cost: each counter's growth while it ran.
Verwendung
Add an interaction budget
Dieser Typ wird verwendet von tests.costOf
import { Pressable, Text, signal } from 'kuito';
import { costOf, press, render, screen, test } from 'kuito/tests';
function Like() {
const liked = signal(false);
return (
<Pressable onPress={() => (liked.value = !liked.value)} opacity={liked.value ? 1 : 0.6}>
<Text>Like</Text>
</Pressable>
);
}
test('a like lays nothing out', async () => {
await render(<Like />);
const cost = await costOf(() => press(screen.getByText('Like')));
cost.toStayWithin({ layoutPasses: 0, measureCalls: 0, viewsCreated: 0 });
});Typdeklaration
export interface Cost extends Readonly<Counts> {
/** Throws, naming every counter over `budget`, when the cost exceeds it. */
toStayWithin(budget: CostBudget): void;
}Mitglieder 14
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
toStayWithin | (budget: CostBudget) => void | Ja | Throws, naming every counter over budget, when the cost exceeds it. |
recordsApplied | number | Ja | Records of the batches applied, the UI thread's prop writes included. |
propWrites | number | Ja | — |
wastedPropWrites | number | Ja | Prop writes of the value the view already had. |
layoutPasses | number | Ja | Layouts that computed at least one node. |
wastedLayoutPasses | number | Ja | Layout passes after which no box changed. |
nodesLaidOut | number | Ja | Nodes the engine computed rather than took from its cache. |
nodesFramed | number | Ja | Boxes the renderer took from a pass. |
wastedFrames | number | Ja | Boxes taken unchanged. |
measureCalls | number | Ja | Leaves measured: each one a miss of the engine's measure cache. |
wastedMeasures | number | Ja | Measures that answered what the leaf measured before it was marked dirty. |
uiEntries | number | Ja | Calls into the UI-thread kernel: operations received, events, frames. |
wastedUiEntries | number | Ja | Events the UI-thread kernel had no handler for. |
viewsCreated | number | Ja | Views made with a native view: a flattened node has none. |
toStayWithin — Methodensignaturen
Signaturen
(budget: CostBudget): voidParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
budget | Partial<Counts> | Ja | — |
Rückgabe
void
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.