I have two examples of the similar program written on Golang. Main aim of that code is sort map of structs using value in the struct.
https://play.golang.org/p/1GojXVahlOz - pointers
https://play.golang.org/p/KsQy95SqqBH - values
In the first example, I use pointers, in the second - values. I'd like to know 2 moments:
-
Which example will be memory-efficient? (I guess it's a pointer way)
-
How to measure performance of these examples, using test data with with different number of structs inside the map? Can you help me with creating Benchmark?
I suppose the size of each struct in the map will vary from 1-2kB in average.
Aucun commentaire:
Enregistrer un commentaire