C. Measurements
This appendix shows MVT's performance cost, as the book's benchmarks measure it. Polling a thousand Pixi containers takes a few microseconds a frame, and hand-written refresh methods don't leave any garbage. Signals beat polling only when very little changes, and the time that polling takes grows with the size of the scene. Each figure comes with an explanation of what it means, and the rest of the book quotes the short version below.
Related: Why Performance Matters · Hot Paths · Measuring Performance · Why Views Poll
C.1 The Short Version
- Polling 1000 Pixi containers takes about 4-13 µs per frame when the scene is at rest, under 0.1% of a 60 fps frame. It rises to 7-19 µs when every container changes. Hand-written refresh methods don't leave any garbage, however much changes, and the JSX runtime leaves 8 bytes a frame when any value changes.
- The JSX runtime takes 1.8-2.7x as long as hand-written refresh methods. That's about 5-9 ns more per container.
- Signals are faster when a few values change, and slower when many do. They win when fewer than about 2-9% of containers change per frame. When every container changes, they take 8-25x as long as polling, and their garbage made the engine collect 271 times a minute, where polling didn't need any collections.
- Scene size matters more than it looks. Past about 1,000 containers, each one takes longer to poll. At 100,000 containers, each takes about 7.5 times as long as at 1,000, and polling the scene at rest takes about 3.7 ms a frame, over a fifth of a 60 fps frame. Skipping inactive parts of the tree with
SKIP_DESCENDANTScut one such frame from 117 µs to 9 µs. - Four of the patterns that the hot path rules warn against are much slower, and two don't make any difference in V8. Over 1000 game objects,
Object.values()is about 30 times slower than reading the properties, and leaves 80 KB of garbage a frame. A template-string key is about 12 times slower (48 KB), and.filter().map()about 4 times (24 KB). Summing 1000 numbers every frame is about 18 times slower than keeping the sum until a version number says one changed, though the summing takes under half a microsecond. That's one check in place of a thousand additions. Checking each of a few numbers for a change takes longer than adding them up again. AMapwith number keys is 1.3 times slower than an array, and a closure made each frame leaves 56 bytes.for...ofand a returned tuple don't take any extra time or memory. - The website's games take 4-10 µs per frame before drawing, well under 0.1% of a frame, and allocate from tens of bytes to about 1 KB a frame.
C.2 The Benchmark Setup
Most of these benchmarks time one frame: the model changes, then the view catches up. The benchmarks don't draw anything, so the figures never include rendering.
- A Pixi container is one
Container, whose properties (x,yandalpha) follow one model record, a plain object such as{ x, y, alpha }. Most benchmarks use 1000 of them. - Dynamic and static properties are properties of each container. A dynamic property is updated every frame from a value in the model, so it can change. A static property is set once, when the scene is built, and never updated after that. "3 dynamic" means
x,yandalphaare all dynamic, and "1 dynamic, 2 static" means onlyxis. - Changed per frame is the share of containers that change in a frame. A container that changes gets a new value in every dynamic property, so this is also the share of dynamic properties that change. 0% is a scene at rest, and 100% means every container changes every frame.
These are the ways of keeping the containers in step with the model:
| Approach | How a change reaches the view |
|---|---|
| MVT (hand-written) | Each container's refresh method reads the model and sets its properties. refreshView calls them all, every frame. This is polling, as Chapter 10 describes it |
| MVT (JSX) | The same polling, built with the JSX runtime from @mvtjs/pixi. Each dynamic property is passed as a getter that reads the model |
| Events | The model calls a listener for each record it changes, and the listener sets the properties |
| Solid signals | The model's values are Solid signals, with one effect per container that sets its properties when they change |
| Model only, without a view | Just the model's own changes, to show how much of a frame they take |
Each cell is the median of two runs, each in its own Node process. Where the two disagreed by more than 5%, a third run decides. Figures are rounded to 3 significant figures. Where the runs still disagreed by more than 5% either way, the cell also shows half the spread between the fastest and slowest run, as a share of the median. So 3.8 ±40% marks a noisy result, and a cell without "±" had runs within 5% of each other. Every run's numbers are in the saved results. Times are in microseconds (µs). A frame at 60 frames per second lasts 16,667 µs.
Measured 2026-10-02 on Intel(R) Core(TM) Ultra 9 185H, win32 10.0.26200, Node.js 26.10.0 (V8 14.6.202.34-node.34), pixi.js 8.21.0, solid-js 1.9.15.
About the figures
Every figure here comes from the one machine above, in Node.js's V8 engine, without drawing anything. Absolute times will differ on other hardware, in browsers, and in other engines. The ratios between approaches usually carry over, and so do the patterns, such as what grows with the size of the scene and what allocates. To get your own numbers, run the benchmarks on your own machine. The benchmarks' README says how.
C.3 Keeping Containers in Step
These tables follow 1000 Pixi containers, each keeping in step with one model record, as the share changed per frame goes from 0% to 100%.
1000 containers, 3 dynamic properties each: time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | model only, no view | MVT (hand-written) | MVT (JSX) | events | Solid signals |
|---|---|---|---|---|---|
| 0% | 0 | 4.96 | 13.3 | 0 | 0.01 |
| 1% | 0.01 | 5.75 | 14 | 0.09 | 2.5 |
| 10% | 0.12 | 6.12 | 14.6 | 1.09 | 23.3 |
| 50% | 0.61 | 7.85 | 16.3 | 5.28 | 117 |
| 100% | 1.2 | 9.8 | 18.9 | 6.67 | 244 |
1000 containers, 1 dynamic property and 2 static properties each: time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | model only, no view | MVT (hand-written) | MVT (JSX) | events | Solid signals |
|---|---|---|---|---|---|
| 0% | 0 | 4.17 | 8.96 | 0 | 0.01 |
| 1% | 0.01 | 4.32 | 9.07 | 0.03 | 1.07 |
| 10% | 0.08 | 4.48 | 9.18 | 0.36 | 10.1 |
| 50% | 0.38 | 5.27 | 10.3 | 2 | 49.1 |
| 100% | 0.8 | 6.66 | 11.9 | 4.18 | 95.5 |
- Polling takes about 4-13 µs per frame for 1000 containers at rest, under 0.1% of a frame. It rises to 7-19 µs when every container changes, mostly because Pixi's setters then have real work to do.
- Signals take very little time at rest, and about 240 ns per changed container. With 1 dynamic property, that's about 100 ns. They're faster than polling until about 2-6% of containers change per frame with 3 dynamic properties, or 4-9% with 1. Past that they're slower, and when every container changes they take 8-25x as long.
- Events are the fastest here, however many containers change, because the model reports only what changed, and the view doesn't have to scan the containers. That is a timing, not a recommendation. Chapter 10 covers the drawbacks of events for a game's design. At 1000 containers, the difference from polling is a few microseconds a frame.
- The JSX runtime takes 1.8-2.7x as long as hand-written refresh methods. That's about 5-9 ns more per container, most of it per container rather than per property. Its refresh methods are closures, without any generated code, so they work under any Content Security Policy. A static property doesn't take any time per frame. So in JSX, pass values that never change as plain values rather than getters.
- The model's own changes are small: at most 1.2 µs per frame, even with every record changed each frame.
C.4 Scaling with Scene Size
These tables grow the same scene, with 3 dynamic properties per container, from 100 to 100,000 containers. The first two divide each frame's time by the number of containers, so a flat column means the time grows in proportion to the scene.
Nothing changed: time per frame per container (ns; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Containers | MVT (hand-written) | MVT (JSX) | Solid signals |
|---|---|---|---|
| 100 | 4.8 | 12.8 | 0.15 |
| 1,000 | 4.97 | 13.1 | 0.01 |
| 10,000 | 11.3 | 16.6 | 0 |
| 100,000 | 37.1 | 49.8 | 0 |
Every container changed each frame: time per frame per container (ns; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Containers | MVT (hand-written) | MVT (JSX) | Solid signals |
|---|---|---|---|
| 100 | 9.96 | 18.6 | 235 |
| 1,000 | 10 | 20.4 | 239 |
| 10,000 | 14.9 | 27.2 | 301 |
| 100,000 | 47 | 60.7 | 435 |
- The time per container is flat up to about 1,000 containers, then climbs. Polling a scene at rest takes about 5 ns per container at 1,000, 11 ns at 10,000 and 37 ns at 100,000. The likeliest cause is that a larger scene no longer fits in the processor's caches. So don't multiply a small scene's figures up to a large one.
- At 100,000 containers, polling a scene at rest takes about 3.7 ms per frame with hand-written refresh methods, and 5.0 ms with the JSX runtime. That's a fifth to a third of a 60 fps frame, before anything is drawn. In scenes that large, skipping inactive parts of the tree is worth doing.
- Signals slow down at scale too. With every container changed each frame, each one takes 239 ns at 1,000 containers and 435 ns at 100,000. That's 43.5 ms a frame, more than two and a half frames' worth.
Every container changed each frame: time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Containers | MVT (hand-written) | MVT (JSX) | Solid signals |
|---|---|---|---|
| 100 | 1 | 1.86 | 23.5 |
| 1,000 | 10 | 20.4 | 239 |
| 10,000 | 149 | 272 | 3,010 |
| 100,000 | 4,690 | 6,070 | 43,500 |
C.5 Occasional Changes and Derived Values
These tables use 1000 Pixi containers again. In the first, each follows a value that changes only now and then, such as a level or a score, and updates two properties when it does. Polling here means noticing the change: comparing with last frame's value by hand, with watch(), or with a reaction made by createReaction.
A value that changes occasionally, updating two properties when it does: time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | compare by hand | watch() | createReaction | events | Solid signals |
|---|---|---|---|---|---|
| 0% | 4.17 | 11.5 | 6.24 | 0 | 0.02 |
| 1% | 4.44 | 11.9 | 6.37 | 0.12 | 1.21 |
| 10% | 5.02 | 12.9 ±8% | 7.34 | 1.28 | 11.2 |
In the second, each container shows a value computed from 8 model values, such as a total. Polling either recomputes it every frame, or uses watch() on all 8 values and recomputes only when one changed, or reads a computed value made by createComputed, which does the same for you. Signals use a createMemo.
A property computed from 8 model values: time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | recompute every frame | watch() | createComputed | events | Solid signals |
|---|---|---|---|---|---|
| 0% | 8.78 | 66.9 | 76.4 | 0 | 0.02 |
| 10% | 8.12 | 69.2 | 84 | 0.91 | 62.8 |
| 100% | 11.5 | 76.8 | 106 | 8.62 | 634 |
watch()takes about 8 ns per watched value per frame. A watcher of one value takes nearly three times as long as comparing by hand. It doesn't allocate anything (see Memory), so the time goes on the calls. At game scale this is still small: 1000 watchers of one value take about 12 µs a frame.- A reaction takes about half as long as
watch(), about 6 ns per frame. On a quiet frame, it only calls its getter and compares the value with the last one. - A computed value takes a little longer than
watch()over the same values: 76 µs a frame here, against 67. Each time it's read, it makes the same checks aswatch(), with a little more work around them. It guards against a computed value that reads itself, and it gathers the values into a record forcomputewhen one has changed. - Recomputing a quick derived value every frame is faster than checking whether it needs recomputing. Summing 8 numbers takes less time than checking 8 numbers for changes. Noticing changes is worth it when the work it skips is slow, such as rebuilding text or changing the scene, not when the work is a little arithmetic. A sum over many numbers can be different: the hot path patterns sum 1000 numbers, and checking one version number in place of them all is about 18 times faster.
- A memo per container is slow when its inputs change often. With every input changed each frame, Solid's memos take about 630 ns per container per frame, against about 12 ns to recompute by polling.
C.6 Building, Destroying and Reusing Containers
The first table is the whole life of one Pixi container with 3 dynamic properties. That's building it and its model record, bringing it up to date once, and destroying it. A bare new Container() and destroy() is included for scale.
One Pixi container and its model record, from construction to destruction (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Scenario | bare container | MVT (hand-written) | MVT (JSX) | events | Solid signals | PixiJS 3D group (hand-written) | PixiJS 3D group (JSX) |
|---|---|---|---|---|---|---|---|
| build, first update, destroy | 0.132 | 0.218 | 0.509 | 0.134 | 0.433 ±31% | 0.742 | 1.06 |
The second is a pool of short-lived items, such as bullets, held in a SlotList. About 500 are alive at once. Either <List> shows the slots, building one container per slot and reusing it for every later item, or a hand-written view builds a container for each new item and destroys it when the item goes.
About 500 short-lived items alive at once: time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| New items per frame | <List> over a SlotList (reuses containers) | build and destroy a container per item |
|---|---|---|
| 5 | 16.7 | 21.4 |
| 50 | 18.2 | 96.2 |
- A container takes about 0.1-0.5 µs over its life, most of it in Pixi's own
Container. With the JSX runtime or signals, it takes about 3-4x as long as a bare container. Building a few containers a frame is quick. Building hundreds is slow. - Reusing containers makes a pool's time per frame the same however fast items come and go. With
<List>, the frame takes about 16-18 µs whether 5 or 50 items appear each frame. Building and destroying takes 20 µs at 5 a frame and 91 µs at 50, and it allocates far more (see Memory).
C.7 The Performance Cost of refreshView
This section measures the time that refreshView itself takes, apart from the work that the refresh methods do. Each refresh method here does very little. refreshView is compared with a plain recursive walk over the tree, which calls every refresh method it finds, and with Pixi's own onRender callbacks. The last scenario has 100 groups of 100 containers, and 90 of the groups are inactive. Those are either only hidden, or return SKIP_DESCENDANTS from their own refresh method.
refreshView and its alternatives (median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Scenario | Approach | Time per frame (µs) | Method calls per frame |
|---|---|---|---|
| 20,000 containers, 200 with a refresh method | plain recursive walk | 197 | 200 |
refreshView | 0.6 | 200 | |
| 2,000 containers, all with a refresh method | plain recursive walk | 8.76 | 2,000 |
Pixi onRender | 1.85 | 2,000 | |
refreshView | 5.34 | 2,000 | |
| 2,000 containers, all with a refresh method, 100 replaced per frame | plain recursive walk | 26.7 | 2,000 |
refreshView | 105 | 2,000 | |
| 100 subtrees of 25 containers without a refresh method, detached and re-attached per frame | plain recursive walk | 39.8 | 1 |
refreshView | 8.32 | 1 | |
100 containers added and removed per frame, no refreshView | @mvtjs/pixi not imported | 11 | 0 |
| @mvtjs/pixi imported | 11.1 | 0 | |
| 10,000 containers with a refresh method each, in 100 groups, 90 groups inactive | inactive groups hidden (visible = false) only | 117 | 10,000 |
inactive groups return SKIP_DESCENDANTS | 9.41 | 1,090 |
refreshViewvisits only the containers that have a refresh method. It keeps a cached list of them, its method list. So in a large scene where only a few containers have one, it's hundreds of times faster than walking the tree: 0.6 µs against 197 µs, for 200 refresh methods among 20,000 containers.- Its worst case is replacing many containers that have a refresh method, every frame. 100 replacements a frame make
refreshViewrebuild its method list every frame, walking the tree to do it. That takes 105 µs, against 27 µs for a plain walk. The@mvtjs/pixiREADME explains why this is accepted. - It takes about 2 ns more per call than Pixi's
onRender. Those 2 ns go on checking for containers removed during the call. - Skipping inactive parts of the tree is worth doing at scale. Returning
SKIP_DESCENDANTSfrom 90 inactive groups cut the frame from 117 µs to 9 µs. Hiding a container withvisible = falsedoesn't stop its refresh methods from running. - Importing
@mvtjs/pixiadds very little time to a tree that never uses it. Once imported, the library watches for changes to the tree, so that it can rebuild its method lists when the tree changes. Even so, adding and removing 100 containers a frame took 11.1 µs with it imported, against 11.0 µs without, which is close to the noise.
C.8 The Hot Path Rules
These tables measure patterns that the hot path rules in Chapter 24 cover. Each pattern is written two ways that compute the same result: the way a rule warns against, and the way it recommends. The work is typical of a game's frame, over 1000 game objects. Each object is a plain record with a position, a velocity and a few stats.
Time per frame (µs; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Rule (per frame, over 1000 game objects unless stated) | Avoid | Prefer |
|---|---|---|
.filter().map() vs an index loop | 3.11 | 0.85 |
for...of vs an index loop | 0.9 | 0.91 |
template-string key into a Map vs arithmetic index into an array | 50.1 | 4.21 |
numeric key into a Map vs index into an array | 5.46 | 4.27 |
forEach with a new closure vs an index loop | 2.46 | 2.46 |
Object.values() vs reading properties | 48 | 1.53 |
returning a [col, row] tuple vs an out-parameter | 4.67 | 4.49 |
| summing 1000 scores every frame vs caching the sum | 0.36 | 0.02 |
100 Text labels: set every frame vs only on change | 0.66 | 0.21 |
Bytes allocated per frame (bytes; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Rule (per frame, over 1000 game objects unless stated) | Avoid | Prefer |
|---|---|---|
.filter().map() vs an index loop | 24,500 | 0 |
for...of vs an index loop | 0 | 0 |
template-string key into a Map vs arithmetic index into an array | 48,000 | 0 |
numeric key into a Map vs index into an array | 0 | 0 |
forEach with a new closure vs an index loop | 56 | 0 |
Object.values() vs reading properties | 80,000 | 0 |
returning a [col, row] tuple vs an out-parameter | 0 | 0 |
| summing 1000 scores every frame vs caching the sum | 0 | 0 |
100 Text labels: set every frame vs only on change | 1 ±44% | 1 ±26% |
- Four patterns clearly matter.
Object.values()per game object is about 30 times slower than reading the properties, and leaves 80 KB of garbage per frame. A template-string key is about 12 times slower (48 KB), and.filter().map()about 4 times (24 KB). Summing 1000 scores every frame is about 18 times slower than keeping the sum until a version number says one changed, though the summing takes under half a microsecond. Where each number must be checked on its own, a sum of a few numbers is faster to recompute, as Occasional Changes shows. - Two don't make any difference in V8. A
for...ofloop over an array runs as fast as an index loop, and doesn't allocate anything. A function that returns a[col, row]tuple doesn't allocate anything either. Once the function is inlined, the engine never builds the array. - Two more matter a little. A
Mapwith number keys is 1.3 times slower than an array, but doesn't leave any garbage. A closure made each frame leaves 56 bytes, and takes too little time to measure. - Pixi's
Textalready skips unchanged text. Setting the same string every frame takes about 7 ns per label. V8 reuses the strings of small numbers, so it doesn't allocate anything. Checking for a change first is still about 3 times faster.
C.9 Memory and Garbage Collection
Garbage is memory that a frame allocates and then drops. The engine reclaims it by pausing to collect it, so a game that allocates every frame collects often. These tables show the bytes each frame allocates, how often the engine collected over one simulated minute, and how much memory each container keeps alive.
"MVT (hand-written, wasteful)" is the hand-written approach, plus building a string and an array every frame, which the hot path rules warn against. It's there to show that the measurement detects allocation when it happens.
1000 containers, 3 dynamic properties each: bytes allocated per frame (bytes; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | MVT (hand-written) | MVT (JSX) | events | Solid signals | MVT (hand-written, wasteful) |
|---|---|---|---|---|---|
| 0% changed | 0 | 0 | 0 | 103 | 96,600 |
| 10% changed | 0 | 8 | 0 | 62,600 | 96,700 |
| 100% changed | 0 | 8 | 0 | 631,000 | 96,700 |
1000 JSX sprites with a fractional width, which the runtime writes only on a change: bytes allocated per frame (bytes; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | MVT (JSX) |
|---|---|
| 0% changed | 0 |
| 100% changed | 0 |
1000 containers reacting to a value that changes occasionally, 10% changed per frame: bytes allocated per frame (bytes; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Changed per frame | compare by hand | watch() | events | Solid signals |
|---|---|---|---|---|
| 10% changed | 0 | 0 | 0 | 30,600 |
About 500 short-lived items, 50 new per frame: bytes allocated per frame (bytes; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| New items per frame | <List> over a SlotList | build and destroy per item |
|---|---|---|
| 50 new per frame | 5,600 | 70,000 |
1000 containers, 3 dynamic properties, all changed every frame, for one simulated minute (3600 frames) (median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Approach | Young-generation collections | Full collections | Time in collections (ms) |
|---|---|---|---|
| MVT (hand-written) | 0 | 0 | 0 |
| MVT (JSX) | 0 | 0 | 0 |
| events | 0 | 0 | 0 |
| Solid signals | 271 | 0 | 36.6 ±14% |
| MVT (hand-written, wasteful) | 41 | 0 | 3.9 |
About 500 short-lived items, 50 new per frame, for one simulated minute (3600 frames) (median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Approach | Young-generation collections | Full collections | Time in collections (ms) |
|---|---|---|---|
<List> over a SlotList | 5 | 0 | 0.8 ±22% |
| build and destroy per item | 14 | 0 | 3.9 |
Memory kept alive per Pixi container and its model record (bytes; median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Measure | bare container | MVT (hand-written) | MVT (JSX) | events | Solid signals |
|---|---|---|---|---|---|
| per container | 713 | 883 | 1,190 | 875 | 2,550 |
- Polling allocates very little. Hand-written refresh methods and
watch()don't allocate anything per frame. The JSX runtime doesn't allocate anything at rest, and allocates 8 bytes a frame when any value changes, however many do. Over a simulated minute with every container changed each frame, the engine never needed to collect. - Signals allocate on every change. Solid's effects left about 630 bytes of garbage per changed container per frame, and about 100 bytes a frame even at rest. With everything changed each frame, that made 271 collections a minute, about 37 ms of pauses. That's six times the garbage of the deliberately wasteful refresh methods.
- Events don't allocate anything in this benchmark, because each record's listener is created once, and called with the record.
- These scenes use whole numbers. V8 stores a whole number without allocating. It may box a fractional number, which means storing it in a small object on the heap, when it stores or passes one. Whether it does can depend on the code nearby. The JSX runtime avoids boxing in the properties it writes only on a change, such as
width. 1000 sprites with a fractionalwidthdon't allocate anything per frame, changed or not. - Reusing containers avoids most of a pool's garbage. With
<List>over aSlotList, the only allocation is the new model records: 5.6 KB a frame at 50 new items. Building and destroying a container per item allocates about 70 KB a frame, and collects about three times as often. - A Pixi container is already about 710 bytes. Following a model record with a hand-written refresh method or an event listener adds about 170 bytes, the record included. The JSX runtime adds about 480, and signals and an effect about 1,800.
C.10 The Website's Games and Demos
The website's games and demos, as they ship, run under Node without drawing anything. The games are driven by a fixed pattern of pretend input: directions change every half second, and buttons are pressed every second or so. The demos run unattended, as they do before anyone touches them. Each frame is what a tick runs: the models' update, then updateView and refreshView on the whole stage. The first 10 seconds are a warm-up, and times are averaged over the minute after. The games were measured before several of them were redrawn, so their figures may have moved a little since.
Time per frame, averaged over one simulated minute (median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Kind | Name | Models (µs) | updateView (µs) | refreshView (µs) | Total (µs) | Pixi containers | Update and refresh methods |
|---|---|---|---|---|---|---|---|
| Game | Astrovoid | 0.85 ±13% | 0.33 ±10% | 4.03 ±9% | 5.12 ±9% | 46 | 22 |
| Burrow Bust | 1.28 ±6% | 0.35 ±16% | 2.74 | 4.37 | 37 | 14 | |
| Crumb Chase | 0.18 | 0.49 ±12% | 4.06 ±6% | 4.79 ±6% | 234 | 11 | |
| Dojo Duel | 1.65 ±20% | 0.4 ±13% | 1.93 ±7% | 3.94 ±12% | 27 | 6 | |
| Fuel Run | 1.09 ±18% | 0.54 ±8% | 3.15 | 4.82 | 84 | 42 | |
| Galaxy Raiders | 3.64 ±13% | 0.42 ±46% | 3.34 | 7.42 ±7% | 79 | 38 | |
| Kwazy Cactii | 0.17 ±8% | 0.71 ±14% | 8.55 | 9.6 | 306 | 76 | |
| Demo | Boids | 507 ±11% | 0.86 ±7% | 15.1 | 523 ±11% | 313 | 33 |
| Falling sand | 1.85 ±7% | 0.74 ±6% | 182 | 184 | 3,890 | 3,790 | |
| Reordering lists | 0.2 ±124% | 0.54 ±19% | 2.3 ±10% | 3.32 ±8% | 46 | 37 |
- Each game takes 4-10 µs per frame, well under 0.1% of a 60 fps frame, before drawing. Drawing isn't measured here, but it's likely to take far longer.
refreshViewtakes the larger share in most games, since that's where the views read the model and set their properties. The models take 0.2-4 µs, andupdateViewunder 1 µs. In Galaxy Raiders, with more going on in its model, the models take longer than the refresh.- Two demos take far longer than any game, for different reasons. Falling sand has a sprite for each grain, about 3,900 containers once its opening scene settles. Its refresh takes about 180 µs, about 47 ns per container while the grains are still. The
falling-sand-scalingresults show how that grows with the number of grains: about 2 ms at 20,000. Boids takes about 0.5 ms, almost all of it in its model, which compares every pair of its 200 boids each frame. - The games allocate a little every frame, from tens of bytes to about 1 KB. The hot path rules aim for zero, and the allocation benchmark is a way to find where it comes from. At these rates the engine collects at most once a minute, for well under a millisecond.
Bytes allocated per frame (median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Kind | Name | Bytes per frame |
|---|---|---|
| Game | Astrovoid | 104 ±7% |
| Burrow Bust | 234 | |
| Crumb Chase | 443 | |
| Dojo Duel | 939 | |
| Fuel Run | 352 | |
| Galaxy Raiders | 224 ±21% | |
| Kwazy Cactii | 19 | |
| Demo | Boids | 34 |
| Falling sand | 17 | |
| Reordering lists | 204 |
Garbage collections over one simulated minute (3600 frames) (median of 2 runs, or 3 where the first 2 disagreed by more than 5%, each in its own process; ± marks runs that disagreed by more than 5%)
| Kind | Name | Young-generation collections | Full collections | Time in collections (ms) |
|---|---|---|---|---|
| Game | Astrovoid | 0 | 0 | 0 |
| Burrow Bust | 0 | 0 | 0 | |
| Crumb Chase | 0 | 0 | 0 | |
| Dojo Duel | 1 ±50% | 0 | 0.1 ±48% | |
| Fuel Run | 0 | 0 | 0 | |
| Galaxy Raiders | 1 | 0 | 0.1 ±83% | |
| Kwazy Cactii | 1 | 0 | 0.4 | |
| Demo | Boids | 0 | 0 | 0 |
| Falling sand | 0 | 0 | 0 | |
| Reordering lists | 0 | 0 | 0 |
C.11 Limits of the Measurements
- Rendering. The benchmarks don't draw anything, so the figures never include Pixi's transform updates and draw calls. When values change, rendering is likely to take longer than anything measured here.
- Browsers. Everything is V8 under Node, on one machine. Other engines, and the same engine in a browser, may differ. Ratios travel better than absolute times.
- Textures and text. The games and demos run with every texture replaced by a 1x1 white texture, because loading a spritesheet needs a browser. Text widths are estimated from the font size, because measuring text needs a canvas.
Appendix D explains how these figures were measured, and why each step is there.