With times under one nanosecond I'm wondering what you're actually 
measuring.  Aggressive optimization could make this an "empty" loop. 
 Synthetic benchmarks like this can be tricky to interpret.


On Wednesday, August 3, 2016 at 7:56:32 AM UTC-4, 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.

Reply via email to