/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® one core |
Each table row shows performance measurements for this Go program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 500 | 0.14 | 0.14 | ? | 536 | 0% 0% 0% 100% |
| 3,000 | 4.68 | 4.68 | 1,524 | 536 | 0% 0% 0% 100% |
| 5,500 | 15.70 | 15.71 | 2,260 | 536 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read spectral-norm benchmark to see what this program should do.
go version go1.1.1 linux/amd64
/* The Computer Language Benchmarks Game * http://benchmarksgame.alioth.debian.org/ * * contributed by K P anonymous */ package main import ( "flag" "fmt" "math" "runtime" "strconv" ) var n = 0 // var n = flag.Int("n", 2000, "count") var nCPU = 4 // var nCPU = flag.Int("ncpu", 4, "number of cpus") type Vec []float64 func (v Vec) Times(ii, n int, u Vec, c chan int) { ul := len(u) for i := ii; i < n; i++ { var vi float64 for j := 0; j < ul; j++ { vi += u[j] / float64(((i+j)*(i+j+1)/2 + i + 1)) } v[i] = vi } c <- 1 } func (v Vec) TimesTransp(ii, n int, u Vec, c chan int) { ul := len(u) for i := ii; i < n; i++ { var vi float64 for j := 0; j < ul; j++ { vi += u[j] / float64(((j+i)*(j+i+1)/2 + j + 1)) } v[i] = vi } c <- 1 } func wait(c chan int) { for i := 0; i < nCPU; i++ { <-c } } func (v Vec) ATimesTransp(u Vec) { x := make(Vec, len(u)) c := make(chan int, nCPU) for i := 0; i < nCPU; i++ { go x.Times(i*len(v)/nCPU, (i+1)*len(v)/nCPU, u, c) } wait(c) for i := 0; i < nCPU; i++ { go v.TimesTransp(i*len(v)/nCPU, (i+1)*len(v)/nCPU, x, c) } wait(c) } func main() { flag.Parse() if flag.NArg() > 0 { n, _ = strconv.Atoi(flag.Arg(0)) } runtime.GOMAXPROCS(nCPU) u := make(Vec, n) for i := range u { u[i] = 1 } v := make(Vec, n) for i := 0; i < 10; i++ { v.ATimesTransp(u) u.ATimesTransp(v) } var vBv, vv float64 for i, vi := range v { vBv += u[i] * vi vv += vi * vi } fmt.Printf("%0.9f\n", math.Sqrt(vBv/vv)) }
Thu, 13 Jun 2013 19:30:40 GMT MAKE: /usr/local/src/go/bin/go build -o spectralnorm.go-3.go_run 0.29s to complete and log all make actions COMMAND LINE: ./spectralnorm.go-3.go_run 5500 PROGRAM OUTPUT: 1.274224153