Mutative vs. Immer Immutable State Update Speed Comparison
In 7 sandbox runs on 2026-11-16 (Mutative 2.0.2 vs Immer), median 1000-item array combined updates fell 295.462ms → 126.116ms (2.34x) and 500-record nested updates 470.486ms → 204.711ms (2.30x).
Across 7 comparative runs with default settings in an isolated sandbox on 2026-11-16, Mutative 2.0.2 was 2.34x faster than Immer for combined state updates, cutting the median time from 295.462ms to 126.116ms, and 2.30x faster for nested state updates, cutting the median time from 470.486ms to 204.711ms. All measured figures can be verified in the raw data (JSON) recorded by running the benchmark directly in this site's isolated environment.
Original README claims and sandbox experiment hypothesis
The Mutative GitHub repository and Mutative official documentation cover a JavaScript library that updates immutable state by directly mutating draft objects. The original README states that when comparing Mutative with Immer, it showed approximately 3.6x faster immutable state update processing speed under identical settings and approximately 6.6x faster speed under each library's default settings.
The experimental hypothesis formulated on this site is to verify whether Mutative's elapsed time (mutativeMs) is shorter than Immer's (immerMs)—resulting in a speedup ratio (speedup) greater than 1—when repeatedly updating array and nested object states using both libraries' default settings in a single Node.js sandbox. We installed the package version cited in the Mutative 2.0.2 release notes and directly compared the two libraries under identical conditions.
Isolated sandbox measurement environment and experimental conditions
The largest difference in conditions compared to the original documentation lies in the measurement targets and execution method. Instead of the original suite of multiple workloads, this experiment compared only the default settings of the two libraries against 1000 array items and 500 nested object records deterministically generated in the sandbox.
Here are the hardware and runtime specifications of the isolated sandbox where the measurements were performed.
- OS and architecture: Ubuntu 24.04.4 LTS (
aarch64) - CPU and memory: Neoverse-N1 x2, CPUQuota 150%, memory 2048MB
- Runtime and target versions: Node.js 24.21.0,
mutative2.0.2 (install time 1.6s, install size 1966870 bytes)
The experiment was structured into two state update scenarios and executed 7 times in total within this site's isolated environment. The combined state update measurement repeatedly executes item additions, modifications, and deletions on a base state containing 1000 array items and 20 object keys. The nested state update measurement repeatedly executes deep-path value modifications on a tree structure consisting of 500 records and 200 child nodes, judging the result as the same direction if speedup is greater than 1 and the opposite direction if it is 1 or less.
Results: elapsed time comparison for combined and nested updates
As measured directly across 7 repeated runs in this site's isolated environment on 2026-11-16 (raw data (JSON)), Mutative recorded shorter elapsed times than Immer in both state update scenarios. The median difference for combined state updates was 169.346ms, and the speedup ratio was 2.34278 (approx. 2.34x) for combined updates and 2.298294 (approx. 2.30x) for nested updates.
- OS
- Ubuntu 24.04.4 LTS
- Processor
- Neoverse-N1 x2, CPUQuota 150%aarch64
- Memory
- 2,048 MB
- Runtime
- Node.js 24.21.0
- Tool tested
- mutative 2.0.2
- Repeats
- 7×
- Measured on
- 2026-11-16
Figure. The same input was measured 7 times. Bars show the median, the line below shows min–max, and dots show each run. Raw data (JSON)
View as table · raw data from 7 runs
| Run | Mutative | Immer |
|---|---|---|
| 1 | 134.3 | 295.5 |
| 2 | 123.9 | 288.8 |
| 3 | 126.1 | 303.9 |
| 4 | 135.0 | 295.6 |
| 5 | 124.4 | 299.4 |
| 6 | 121.0 | 286.5 |
| 7 | 127.1 | 291.9 |
| Median | 126.1 | 295.5 |
| Min | 121.0 | 286.5 |
| Max | 135.0 | 303.9 |
| Run | Mutative | Immer |
|---|---|---|
| 1 | 208.3 | 485.8 |
| 2 | 203.8 | 467.8 |
| 3 | 204.7 | 471.6 |
| 4 | 209.5 | 468.5 |
| 5 | 205.9 | 478.5 |
| 6 | 202.0 | 456.9 |
| 7 | 203.4 | 470.5 |
| Median | 204.7 | 470.5 |
| Min | 202.0 | 456.9 |
| Max | 209.5 | 485.8 |
| Metric | Median (ms) | Min (ms) | Max (ms) | Speedup (speedup) |
|---|---|---|---|---|
Combined state update — Mutative (mutativeMs) | 126.116 | 121.022 | 135.002 | 2.34278 |
Combined state update — Immer (immerMs) | 295.462 | 286.536 | 303.948 | Baseline (1) |
Nested state update — Mutative (mutativeNestedMs) | 204.711 | 201.967 | 209.486 | 2.298294 |
Nested state update — Immer (immerNestedMs) | 470.486 | 456.851 | 485.791 | Baseline (1) |
Across all 7 runs (as of 2026-11-16, raw data (JSON)), run-to-run variance remained small. For combined state updates, Mutative stayed between 121.022ms and 135.002ms in every run, while Immer stayed between 286.536ms and 303.948ms.
| Run | mutativeMs (ms) | immerMs (ms) | mutativeNestedMs (ms) | immerNestedMs (ms) | Total wallMs (ms) |
|---|---|---|---|---|---|
| Run 1 | 134.29 | 295.462 | 208.306 | 485.791 | 1419.125 |
| Run 2 | 123.877 | 288.828 | 203.795 | 467.765 | 1368.061 |
| Run 3 | 126.116 | 303.948 | 204.711 | 471.638 | 1420.404 |
| Run 4 | 135.002 | 295.644 | 209.486 | 468.459 | 1368.124 |
| Run 5 | 124.39 | 299.449 | 205.9 | 478.496 | 1421.183 |
| Run 6 | 121.022 | 286.536 | 201.967 | 456.851 | 1321.416 |
| Run 7 | 127.12 | 291.932 | 203.367 | 470.486 | 1368.184 |
Directional comparison between original claims and experimental results
Under these conditions, speedup for combined state updates was 2.34278 and nestedSpeedup for nested state updates was 2.298294, both exceeding the baseline value of 1. The finding that Mutative operates faster than Immer under default settings aligns directionally with the claim in the original README.
However, there is a difference between the figures presented in the original README—6.6x under default settings and 3.6x under identical settings—and the measured multiples in this sandbox (2.34x and 2.30x). While the original benchmark measured a suite of array, object, and set workloads of varying sizes across separate processes, this experiment repeatedly measured only structures of 1000 array items, 500 records, and 200 child nodes within a single process.
Regarding behavioral differences in default settings, the Immer API documentation and the Immer default auto-freeze commit specify that Immer enables setAutoFreeze by default to recursively freeze generated state trees. Conversely, the Mutative official documentation explains that it does not auto-freeze state by default—freezing only when requested—and copies objects along modified paths at most once (1 time). However, how much these differences in default settings and workload conditions contributed to the specific multiplier differences in this experiment cannot be determined from this measurement alone.
Experiment reproduction script
Below is the full Node.js reproduction script used for the measurements. After warmup runs, it sequentially measures combined state updates and nested state updates, outputting the JSON result to standard output.
import { performance } from "node:perf_hooks";
import { create } from "mutative";
import { produce } from "immer";
function buildBaseState() {
const state = {
foo: "bar",
list: Array.from({ length: 1000 }, (_, i) => ({
id: i,
text: `coding-${i}`,
count: i % 7,
active: i % 2 === 0
}))
};
for (let k = 0; k < 20; k++) {
state[`key${k}`] = `value-${k}`;
}
return state;
}
function buildNestedState() {
return {
records: Array.from({ length: 500 }, (_, i) => ({
id: i,
profile: {
name: `user-${i}`,
score: i * 3,
flags: { verified: i % 2 === 0, level: i % 5 }
}
})),
tree: {
nodes: Array.from({ length: 200 }, (_, j) => ({
id: j,
branch: {
leaf: {
weight: j,
active: j % 3 === 0
}
}
}))
}
};
}
const baseState = buildBaseState();
const nestedState = buildNestedState();
function combinedRecipe(draft, step) {
draft.foo = `updated-${step}`;
draft.key0 = `changed-${step}`;
draft.key10 = `changed-${step}`;
draft.list.push({ id: 1000 + step, text: "learning", count: step, active: true });
for (let i = 0; i < 50; i++) {
const idx = (step + i * 19) % 1000;
draft.list[idx].count += 1;
draft.list[idx].active = !draft.list[idx].active;
}
draft.list.pop();
}
function nestedRecipe(draft, step) {
for (let i = 0; i < 40; i++) {
const rIdx = (step + i * 11) % 500;
draft.records[rIdx].profile.score += 1;
draft.records[rIdx].profile.flags.verified = !draft.records[rIdx].profile.flags.verified;
}
for (let j = 0; j < 25; j++) {
const nIdx = (step + j * 7) % 200;
draft.tree.nodes[nIdx].branch.leaf.weight += 2;
draft.tree.nodes[nIdx].branch.leaf.active = !draft.tree.nodes[nIdx].branch.leaf.active;
}
}
for (let w = 0; w < 50; w++) {
create(baseState, (draft) => combinedRecipe(draft, w));
produce(baseState, (draft) => combinedRecipe(draft, w));
create(nestedState, (draft) => nestedRecipe(draft, w));
produce(nestedState, (draft) => nestedRecipe(draft, w));
}
const iterations = 800;
const t0 = performance.now();
for (let i = 0; i < iterations; i++) {
create(baseState, (draft) => combinedRecipe(draft, i));
}
const mutativeMs = Number((performance.now() - t0).toFixed(3));
const t1 = performance.now();
for (let i = 0; i < iterations; i++) {
produce(baseState, (draft) => combinedRecipe(draft, i));
}
const immerMs = Number((performance.now() - t1).toFixed(3));
const t2 = performance.now();
for (let i = 0; i < iterations; i++) {
create(nestedState, (draft) => nestedRecipe(draft, i));
}
const mutativeNestedMs = Number((performance.now() - t2).toFixed(3));
const t3 = performance.now();
for (let i = 0; i < iterations; i++) {
produce(nestedState, (draft) => nestedRecipe(draft, i));
}
const immerNestedMs = Number((performance.now() - t3).toFixed(3));
console.log(JSON.stringify({ mutativeMs, immerMs, mutativeNestedMs, immerNestedMs }));
Measurement limitations and library selection criteria
These results hold only under the condition of updating states at the scale of 1000 array items and 500 records using default settings in an isolated environment running Ubuntu 24.04.4 LTS (aarch64), Neoverse-N1 x2 (CPUQuota 150%), 2048MB memory, and Node.js 24.21.0. Performance when aligning auto-freeze options across both libraries, generating JSON patches, or updating Map and Set collections is outside the scope of measurement and cannot be determined from this experiment alone.
In production projects that require repeatedly updating immutable states at the scale of many array items or nested records at short intervals and need 2.30x to 2.34x faster processing speed under default settings, adopting Mutative 2.0.2 is advantageous. Conversely, if state update frequency is low enough that cumulative differences in the hundreds of milliseconds do not become a bottleneck, and maintaining full returned-state auto-freeze (setAutoFreeze) protection without extra configuration alongside existing Immer API compatibility is required, keeping Immer is suitable.
Related posts
ollama-js 0.6.4 Behavior and Adoption Criteria From Benchmarks
2026-11-10 isolated test (/lab/ollama-js-first-run.json): ollama-js 0.6.4 loaded (10.496ms) and encoded images (0.059ms) with no server; list (43.18ms) and chat (4.398ms) failed with TypeError.
Handlebars.js vs Mustache Rendering: Measured 1.172164x Faster
2026-11-21 (Node.js 24.21.0, 1000 records, 5 runs): Handlebars.js 4.7.10 median 186.439ms, 1.172164x faster than Mustache (218.537ms). 1 fixed template has a small gap; compatibility options decide.
cbor-x 1.6.9 vs. Node.js Built-in JSON: Serialization Speed and Size
In 7 isolated runs (1000 records, Node.js 24.21.0, 2026-11-17), cbor-x 1.6.9 was slower than built-in JSON (total median 622.876 ms vs 445.555 ms) but cut output: 208297 B to 161665 B (-22.387264%).
Written by AI from public sources; numbers and claims are checked against those sources before publishing.