tests.Cost
What an interaction cost: each counter's growth while it ran.
Utilisation
Add an interaction budget
Ce type est utilisé par 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 });
});Déclaration du type
export interface Cost extends Readonly<Counts> {
/** Throws, naming every counter over `budget`, when the cost exceeds it. */
toStayWithin(budget: CostBudget): void;
}Membres 14
| Nom | Type | Requis | Description |
|---|---|---|---|
toStayWithin | (budget: CostBudget) => void | Oui | Throws, naming every counter over budget, when the cost exceeds it. |
recordsApplied | number | Oui | Records of the batches applied, the UI thread's prop writes included. |
propWrites | number | Oui | — |
wastedPropWrites | number | Oui | Prop writes of the value the view already had. |
layoutPasses | number | Oui | Layouts that computed at least one node. |
wastedLayoutPasses | number | Oui | Layout passes after which no box changed. |
nodesLaidOut | number | Oui | Nodes the engine computed rather than took from its cache. |
nodesFramed | number | Oui | Boxes the renderer took from a pass. |
wastedFrames | number | Oui | Boxes taken unchanged. |
measureCalls | number | Oui | Leaves measured: each one a miss of the engine's measure cache. |
wastedMeasures | number | Oui | Measures that answered what the leaf measured before it was marked dirty. |
uiEntries | number | Oui | Calls into the UI-thread kernel: operations received, events, frames. |
wastedUiEntries | number | Oui | Events the UI-thread kernel had no handler for. |
viewsCreated | number | Oui | Views made with a native view: a flattened node has none. |
toStayWithin — signatures de méthode
Signatures
(budget: CostBudget): voidParamètres
| Nom | Type | Requis | Description |
|---|---|---|---|
budget | Partial<Counts> | Oui | — |
Retourne
void
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.