On MacBook Pro, 2.6 GHz Intel Core i7, 8 GB 1600 MHz memory, you benchmarks look pretty consistent:
BenchmarkStart-4 2000000000 1.45 ns/op BenchmarkEnd-4 2000000000 1.47 ns/op BenchmarkHereThere-4 2000000000 1.46 ns/op BenchmarkStartEnd-4 2000000000 1.46 ns/op BenchmarkEndStart-4 2000000000 1.46 ns/op BenchmarkFirst-4 2000000000 0.59 ns/op BenchmarkSecond-4 2000000000 0.59 ns/op BenchmarkLast-4 2000000000 0.59 ns/op BenchmarkPenultimate-4 2000000000 0.58 ns/op On Wednesday, August 3, 2016 at 5:56:32 AM UTC-6, Ondrej wrote: > > I wanted to see if there was a difference when loading values from a > large-ish slice (10000 elements) - to see if caches, locality and other > things had any meaningful impacts. Whilst individual value loading (just a > single element) seemed to be equally fast regardless of element position > (see bench of First, Second, Last, Penultimate), when combining loading of > various values, there seem to be almost a 2.5x difference between loading > first four values and loading last four values (first two benchmarks). > Loading the same values, just in different order, also yields different > execution times. But alternating loading (0, n, 1, n-1) seems to be faster > than loading first two values and last two values. > > (Setting the test slice to be an array instead wipes all differences > between benchmarks.) > > Can anyone point me to a resource - be it Go specific or on computer > science principles - that would explain these large differences? > > Thanks! > > https://play.golang.org/p/oMqDvXI9YW > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.