I measured how long it takes to access an element on array in three ways: 
array, slice, unsafe.Pointer

https://play.golang.org/p/Ofz3u8_AZe

BenchmarkArray  : 50000000        25.7 ns/op
BenchmarkSlice  : 20000000        59.1 ns/op
BenchmarkPointer: 300000000         6.85 ns/op
BenchmarkC      : 2000000000         0.00 ns/op

I know array and slice is relatively slow as they checks for an index to be 
out of bounds when accessing, but I am astounding that there is the huge 
difference between array and slice. Can you explain or give me some link 
about that?

-- 
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