Skip to content

Latest commit

 

History

History
44 lines (30 loc) · 3.9 KB

README.md

File metadata and controls

44 lines (30 loc) · 3.9 KB

Benchmark of deep immutable setters

This project exercises several different utilities for deep-setting immutable data.

Note that these numbers ONLY reflect set operations. Many of these libraries also offer get functionality, so the final bundle size will depend on your use cases. These are for reference only.

Usage

To run this locally:

yarn install;
yarn run benchmark;

Results

Lower times are better .Last run on September 12, 2020.

Library Version Bundle size Total time ["prop1", "prop2", "prop3"] "prop1.prop2.prop3" "prop1[prop2][prop3]"
Immer 7.0.8 gzip size 27.447886964 8.907073234 9.249547088 9.291266642
Immutable.js 4.0.0-rc.12 gzip size (pending) (pending) (pending) (pending)
immutable-assign (iassign.js) 2.1.4 gzip size (pending) (pending) (pending) (pending)
lodash (setWith + clone) 4.17.20 gzip size 4.662552397 1.23424402 1.784842394 1.854285601
seamless-immutable 7.1.4 gzip size (pending) (pending) (pending) (pending)
tiny-immutable-set 0.1.0 gzip size 4.702447091 2.191983945 1.447061770 1.63401376

Organization

Each library has a file under libraries/ which provides a callback for each scenario:

  • setWithString(object, path, value), where path looks like "prop1.prop2.prop3"
  • setWithArray(object, path, value), where path looks like ["prop1", "prop2", "prop3"]
  • setWithArrayString(object, path, value), where path looks like "prop1[prop2][prop3]"

Each scenario type has a file under scenarios/ which provides setup and teardown callbacks:

  • setup(numCasesToGenerate) returns an array of (object, path, value) arguments to use for each test case
  • teardown(cases) is available if you need it

run-benchmark.js runs everything based on the libraries and scenarios exported from each directory's index.js, with some additional settings in options.js.