Hi Solokov,

interesting idea, but it does not seem that the cache size would be the 
issue at hand here — please note that slices of more than 524288 integers 
do not fit in my laptop cache:

 1. The runtime is linear to the size of the array (no "cliff" — see 
attached picture)

 2. The page misses are ridiculously low (expected since the benchmark 
yields itself to contiguous allocation and processing):

 Performance counter stats for '/usr/local/go/bin/go test -bench=.':

      20882.464799      task-clock (msec)         #    0.998 CPUs 
utilized          
             4,947      context-switches          #    0.237 
K/sec                  
               239      cpu-migrations            #    0.011 
K/sec                  
            23,583      page-faults               #    0.001 
M/sec                  
    64,142,963,898      cycles                    #    3.072 
GHz                    
    37,246,686,615      instructions              #    0.58  insn per 
cycle         
     4,753,144,504      branches                  #  227.614 
M/sec                  
         2,870,298      branch-misses             #    0.06% of all 
branches  

I am running the following excerpt from the original code:
package P

import (
    "strconv"
    "testing"
)

func memclr(a []int) {
    for i := range a {
        a[i] = 0
    }
}

func BenchmarkMemclr(b *testing.B) {
    for i := 100000; i < 409600000; i *= 2 {
        b.Run("bench"+strconv.Itoa(i), func(b *testing.B) {
            var a = make([]int, i)
            b.ResetTimer()
            for i := 0; i < b.N; i++ {
                memclr(a)
            }
        })
    }
}



<https://lh3.googleusercontent.com/-tHycMAwzjj0/WFOyepsWGKI/AAAAAAAAAAM/L2f8MPAr9BMsyC5jTrfBIZnekJeqrALIQCLcB/s1600/running_time.png>

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