I've been doing some experimenting with immer. I really like how much simpler it is to write reducers with it!
I was doing some benchmarking vs ImmutableJS and wanted to check if my results make sense.
The benchmark looks like this:
- Trigger a single action which is handled by one reducer
- The reducer produces a new state by appending the item's id to the end of an array and adding the item into a map (or plain JS object for immer)
I'm triggering the action 3,000 times, and then measuring the performance of triggering the action another 1,000 times.
The immutable JS reducer takes about 400ms, and the immer reducer takes about 4 seconds. Here's the immer profile:

It looks like the main cost is incurred by producing copies of the state as the state is supposed to be immutable, which has to happen for each triggered action. And that's also the main part that ImmutableJS is able to optimize away.
I just wanted to check with you on whether that basically made sense and whether you had any thoughts on it. (When running immer, proxies are used and freezing is off. Browser is Chrome.)
Thanks,
Chris
I've been doing some experimenting with immer. I really like how much simpler it is to write reducers with it!
I was doing some benchmarking vs ImmutableJS and wanted to check if my results make sense.
The benchmark looks like this:
I'm triggering the action 3,000 times, and then measuring the performance of triggering the action another 1,000 times.
The immutable JS reducer takes about 400ms, and the immer reducer takes about 4 seconds. Here's the immer profile:
It looks like the main cost is incurred by producing copies of the state as the state is supposed to be immutable, which has to happen for each triggered action. And that's also the main part that ImmutableJS is able to optimize away.
I just wanted to check with you on whether that basically made sense and whether you had any thoughts on it. (When running immer, proxies are used and freezing is off. Browser is Chrome.)
Thanks,
Chris