tests.Cost
What an interaction cost: each counter's growth while it ran.
Utilização
Add an interaction budget
Este tipo é usado por 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 });
});Declaração do tipo
export interface Cost extends Readonly<Counts> {
/** Throws, naming every counter over `budget`, when the cost exceeds it. */
toStayWithin(budget: CostBudget): void;
}Membros 14
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
toStayWithin | (budget: CostBudget) => void | Sim | Throws, naming every counter over budget, when the cost exceeds it. |
recordsApplied | number | Sim | Records of the batches applied, the UI thread's prop writes included. |
propWrites | number | Sim | — |
wastedPropWrites | number | Sim | Prop writes of the value the view already had. |
layoutPasses | number | Sim | Layouts that computed at least one node. |
wastedLayoutPasses | number | Sim | Layout passes after which no box changed. |
nodesLaidOut | number | Sim | Nodes the engine computed rather than took from its cache. |
nodesFramed | number | Sim | Boxes the renderer took from a pass. |
wastedFrames | number | Sim | Boxes taken unchanged. |
measureCalls | number | Sim | Leaves measured: each one a miss of the engine's measure cache. |
wastedMeasures | number | Sim | Measures that answered what the leaf measured before it was marked dirty. |
uiEntries | number | Sim | Calls into the UI-thread kernel: operations received, events, frames. |
wastedUiEntries | number | Sim | Events the UI-thread kernel had no handler for. |
viewsCreated | number | Sim | Views made with a native view: a flattened node has none. |
toStayWithin — assinaturas de método
Assinaturas
(budget: CostBudget): voidParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
budget | Partial<Counts> | Sim | — |
Devolve
void
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.