performance measurements

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
5000.130.14?411  7% 0% 93% 0%
3,0004.684.681,024411  1% 0% 0% 100%
5,50015.7015.691,288411  0% 1% 100% 1%

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.

 notes

go version go1.4 linux/amd64

 spectral-norm Go program source code

/* The Computer Language Benchmarks Game
 * http://benchmarksgame.alioth.debian.org/
 *
 * contributed by chaishushan
 * Based on spectral-norm.go by The Go Authors.
 */

package main

import (
   "flag"
   "fmt"
   "math"
   "strconv"
)

// var n = flag.Int("n", 2000, "count")
var n = 0

func evalA(i, j int) int { return ((i+j)*(i+j+1)/2 + i + 1) }

type Vec []float64

func (v Vec) Times(u Vec) {
   for i := 0; i < len(v); i++ {
      v[i] = 0
      for j := 0; j < len(u); j++ {
         v[i] += u[j] / float64(evalA(i, j))
      }
   }
}

func (v Vec) TimesTransp(u Vec) {
   for i := 0; i < len(v); i++ {
      v[i] = 0
      for j := 0; j < len(u); j++ {
         v[i] += u[j] / float64(evalA(j, i))
      }
   }
}

func (v Vec) ATimesTransp(u Vec) {
   x := make(Vec, len(u))
   x.Times(u)
   v.TimesTransp(x)
}

func main() {
   flag.Parse()
   if flag.NArg() > 0 {
      n, _ = strconv.Atoi(flag.Arg(0))
   }

   N := n
   u := make(Vec, N)
   for i := 0; i < N; i++ {
      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 := 0; i < N; i++ {
      vBv += u[i] * v[i]
      vv += v[i] * v[i]
   }
   fmt.Printf("%0.9f\n", math.Sqrt(vBv/vv))
}

 make, command-line, and program output logs

Thu, 11 Dec 2014 08:54:40 GMT

MAKE:
/usr/local/src/go/bin/go build -o spectralnorm.go_run
0.53s to complete and log all make actions

COMMAND LINE:
./spectralnorm.go_run 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play