Did you tested with structs?
I changed statsHolder := make([]Stats, 0, 11664000) to statsHolder := *new([]Stats) but performance diff is 4x. First one works in ~500ms but second one almost take 2 second. I uploaded example benchmark to here.
That will be there. Basically the difference is due to pre-allocation of memory vs on-demand allocation and resizing. See my later comment reply: dev.to/freakynit/comment/1k4fk
Nice point. We must try it in benchmarks.
Did the benchmarks. Here is the code and the results: gist.github.com/freakynit/69cacf64...
Observation:
Eager Dereferenced
version usingnew
always beat other two (non-eager-dereferenced
andmake
).Did you tested with structs?
I changed
statsHolder := make([]Stats, 0, 11664000)
tostatsHolder := *new([]Stats)
but performance diff is 4x. First one works in ~500ms but second one almost take 2 second. I uploaded example benchmark to here.That will be there. Basically the difference is due to pre-allocation of memory vs on-demand allocation and resizing. See my later comment reply: dev.to/freakynit/comment/1k4fk
Oh I understand now. Thanks for answer 👍