planttheidea / fast-copy

A blazing fast deep object copier
MIT License
1.13k stars 31 forks source link

perf(cache length of array, object): improve performance #22

Closed IWANABETHATGUY closed 4 years ago

IWANABETHATGUY commented 4 years ago

Though jit compiler will automatically optimization the iteration, but the warm up may cost some time, here is the benchmark comparison before and after the change. before: image after: image

test on MacBook Pro (2.3 GHz Intel Core i5)

IWANABETHATGUY commented 4 years ago

image only cache length if object is an Array, here is the benchmark

planttheidea commented 4 years ago

Thank you for the PR! This change has been released as part of 2.0.4.