Home / File/ kairo_avoidable.bench.js — svelte Source File

kairo_avoidable.bench.js — svelte Source File

Architecture documentation for kairo_avoidable.bench.js, a javascript file in the svelte codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  0a4d017d_ab62_043a_9842_5ea5ee838412["kairo_avoidable.bench.js"]
  23b3e1d7_5601_87e8_cdcc_d7ed42c18fd9["util.js"]
  0a4d017d_ab62_043a_9842_5ea5ee838412 --> 23b3e1d7_5601_87e8_cdcc_d7ed42c18fd9
  25e30d63_2aff_c8ae_05a6_54771360691c["busy"]
  0a4d017d_ab62_043a_9842_5ea5ee838412 --> 25e30d63_2aff_c8ae_05a6_54771360691c
  d3dc1520_5a13_e6ad_9208_466ecffe2410["node:assert"]
  0a4d017d_ab62_043a_9842_5ea5ee838412 --> d3dc1520_5a13_e6ad_9208_466ecffe2410
  1a59b12b_63d5_2eb4_1881_6fb96dbdcb56["client"]
  0a4d017d_ab62_043a_9842_5ea5ee838412 --> 1a59b12b_63d5_2eb4_1881_6fb96dbdcb56
  style 0a4d017d_ab62_043a_9842_5ea5ee838412 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import assert from 'node:assert';
import * as $ from 'svelte/internal/client';
import { busy } from '../util.js';

export default () => {
	let head = $.state(0);
	let computed1 = $.derived(() => $.get(head));
	let computed2 = $.derived(() => ($.get(computed1), 0));
	let computed3 = $.derived(() => (busy(), $.get(computed2) + 1)); // heavy computation
	let computed4 = $.derived(() => $.get(computed3) + 2);
	let computed5 = $.derived(() => $.get(computed4) + 3);

	const destroy = $.effect_root(() => {
		$.render_effect(() => {
			$.get(computed5);
			busy(); // heavy side effect
		});
	});

	return {
		destroy,
		run() {
			$.flush(() => {
				$.set(head, 1);
			});
			assert.equal($.get(computed5), 6);
			for (let i = 0; i < 1000; i++) {
				$.flush(() => {
					$.set(head, i);
				});
				assert.equal($.get(computed5), 6);
			}
		}
	};
};

Dependencies

Frequently Asked Questions

What does kairo_avoidable.bench.js do?
kairo_avoidable.bench.js is a source file in the svelte codebase, written in javascript. It belongs to the ReactivityBenchmarks domain.
What does kairo_avoidable.bench.js depend on?
kairo_avoidable.bench.js imports 4 module(s): busy, client, node:assert, util.js.
Where is kairo_avoidable.bench.js in the architecture?
kairo_avoidable.bench.js is located at benchmarking/benchmarks/reactivity/tests/kairo_avoidable.bench.js (domain: ReactivityBenchmarks, directory: benchmarking/benchmarks/reactivity/tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free