dlv icon indicating copy to clipboard operation
dlv copied to clipboard

Shrink by using reduce

Open mikesherov opened this issue 5 years ago • 4 comments

Before:

        122 B: dlv.js.gz
         91 B: dlv.js.br
        121 B: dlv.es.js.gz
         97 B: dlv.es.js.br
        198 B: dlv.umd.js.gz
        160 B: dlv.umd.js.br

After:

        117 B: dlv.js.gz
         82 B: dlv.js.br
        116 B: dlv.es.js.gz
         81 B: dlv.es.js.br
        188 B: dlv.umd.js.gz
        148 B: dlv.umd.js.br

this is smaller than the for in patch, and more performant by looking at this esbench. On par with the for loop: https://esbench.com/bench/5ce6eafa4cd7e6009ef6252b image

mikesherov avatar May 23 '19 18:05 mikesherov

On par with the for loop: esbench.com/bench/5ce6e64a4cd7e6009ef62526

Looks like your link doesn't have reduce version, could you recheck/update please?

RReverser avatar May 23 '19 23:05 RReverser

https://esbench.com/bench/5ce6eafa4cd7e6009ef6252b

mikesherov avatar May 23 '19 23:05 mikesherov

Thanks! As expected, particular results differ between browsers - this one is from Firefox - but at least it's indeed better perf-wise than for-in version:

image

RReverser avatar May 23 '19 23:05 RReverser

Sorry for taking so long to reply here. The benchmark needs a bunch of different source objects and many variants of key in order to produce valid results. Currently since it's the same object and key passed every time, it's benchmarking a cache.

developit avatar Jul 29 '19 18:07 developit