On my AMD 5950x I get 1m26.273s vs 2m30.918s The huge time difference (3m vs 18m) in your times could be due to thermal throttling or core clock boost strategy e.g. The CPU may boost clocks high for a short while and then drop down.
You can disable intel turbo boost and set a static core clock to rule that out. Not much you can do for thermal throttling unless you underclock until it doesn't thermal throttle. On Friday, 26 March 2021 at 3:02:52 am UTC+8 Isaac Gouy wrote: > ( > Yeah, it's a tiny tiny program from someone's language comparison > <http://www.hildstrom.com/projects/langcomp/index.html#:~:text=Results%20Table%20%20%20%20%20%20,%20%20225.9%20%2016%20more%20rows%20> > > but this is a hugely bigger slowdown than gcc or java? > > The code change is compile time constant — > array_length int = 100000000 > > — changed to run time value — > array_length int = 1000000 * iterations > ) > > > package main > import "os" > import "fmt" > import "strconv" > func main() { > var ( > element, iteration, iterations, innerloop int > sum float64 > ) > > if len(os.Args) > 1 { > iterations,_ = strconv.Atoi(os.Args[1]) > } > fmt.Printf("iterations %d\n", iterations) > > var ( > array_length int = 100000000 > array []float64 = make([]float64, array_length) > ) > > for element = 0; element < array_length; element++ { > array[element] = float64(element) > } > for iteration = 0; iteration < iterations; iteration++ { > for innerloop = 0; innerloop < 1000000000; innerloop++ { > sum += array[(iteration + innerloop) % array_length] > } > } > fmt.Printf("sum %E\n", sum) > array = nil > } > > $ /opt/src/go1.16/go/bin/go build -o out test.go > $ time ./out 100 > iterations 100 > sum 5.000000E+18 > > real 3m3.225s > > ==== > > package main > import "os" > import "fmt" > import "strconv" > func main() { > var ( > element, iteration, iterations, innerloop int > sum float64 > ) > > if len(os.Args) > 1 { > iterations,_ = strconv.Atoi(os.Args[1]) > } > fmt.Printf("iterations %d\n", iterations) > > var ( > array_length int = 1000000 * iterations > array []float64 = make([]float64, array_length) > ) > > for element = 0; element < array_length; element++ { > array[element] = float64(element) > } > for iteration = 0; iteration < iterations; iteration++ { > for innerloop = 0; innerloop < 1000000000; innerloop++ { > sum += array[(iteration + innerloop) % array_length] > } > } > fmt.Printf("sum %E\n", sum) > array = nil > } > > $ /opt/src/go1.16/go/bin/go build -o out test.go > $ time ./out 100 > iterations 100 > sum 5.000000E+18 > > real 18m20.737s > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4932c78a-8f52-49c8-8d2a-cbdd102a06d3n%40googlegroups.com.