Yomguithereal / baobab

JavaScript & TypeScript persistent and optionally immutable data tree with cursors.
MIT License
3.15k stars 115 forks source link

Increase performance deep clone of Object #496

Closed anthony-redFox closed 6 years ago

anthony-redFox commented 6 years ago

Removed defineProperty for general properties. Removed type.lazyGetter it is also get getOwnPropertyDescriptor.

anthony-redFox commented 6 years ago

Origin benchmark Baobab#get x 586,850 ops/sec ±0.34% (93 runs sampled) Baobab#set x 114,998 ops/sec ±0.30% (91 runs sampled) Baobab#unset x 832,289 ops/sec ±0.81% (95 runs sampled) Baobab.Cursor#set x 29,060 ops/sec ±2.99% (89 runs sampled) Baobab.Cursor#unset x 805,899 ops/sec ±0.35% (94 runs sampled) Baobab.Cursor#push x 1,133 ops/sec ±43.11% (11 runs sampled) Baobab.Cursor#unshift x 490 ops/sec ±1.57% (83 runs sampled) Baobab.Cursor#splice x 563 ops/sec ±0.25% (92 runs sampled)

With patch Baobab#get x 583,150 ops/sec ±1.03% (92 runs sampled) Baobab#set x 168,024 ops/sec ±0.90% (92 runs sampled) Baobab#unset x 826,162 ops/sec ±0.77% (93 runs sampled) Baobab.Cursor#set x 37,739 ops/sec ±2.72% (88 runs sampled) Baobab.Cursor#unset x 780,711 ops/sec ±3.35% (89 runs sampled) Baobab.Cursor#push x 1,133 ops/sec ±45.25% (10 runs sampled) Baobab.Cursor#unshift x 482 ops/sec ±1.45% (79 runs sampled) Baobab.Cursor#splice x 543 ops/sec ±2.55% (91 runs sampled)

Set operation is better 1.5 times.

anthony-redFox commented 6 years ago

@Yomguithereal any update?

Yomguithereal commented 6 years ago

I am not sure to understand your changes. Is your point to "factor" calls to property descriptors to avoid impacting perf?

anthony-redFox commented 6 years ago

@Yomguithereal yes, you right.

Chrome 63

image

Yomguithereal commented 6 years ago

Fair enough. Let's merge. Thanks @anthony-redFox. Will you be needing a npm release soon?

anthony-redFox commented 6 years ago

@Yomguithereal Yes, please. Thanks a lot.