/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® quad-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,000 | 0.16 | 0.16 | ? | 405 | 0% 94% 0% 0% |
| 5,000,000 | 1.43 | 1.43 | 2,852 | 405 | 1% 1% 0% 99% |
| 50,000,000 | 13.99 | 14.00 | 2,852 | 405 | 90% 11% 0% 0% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read thread-ring benchmark to see what this program should do.
go version go1.1.1 linux/386
/* The Computer Language Benchmarks Game http://benchmarksgame.alioth.debian.org/ contributed by KP */ package main import ( "fmt" "os" "runtime" "strconv" "sync" ) type Token int type T struct { next *T label int value int mux sync.Mutex } func (w *T) put(v int) { w.value = v if v == 0 { res <- w.label } else { w.mux.Unlock() } } func (w *T) run() { for { w.mux.Lock() w.next.put(w.value - 1) runtime.Gosched() } } func (w *T) Start(label int, next *T) { w.label = label w.next = next w.mux.Lock() go w.run() } const NThreads = 503 var res = make(chan int) func main() { n := 1000 if len(os.Args) > 1 { n, _ = strconv.Atoi(os.Args[1]) } var channels [NThreads]T for i := range channels { channels[i].Start(i+1, &channels[(i+1)%NThreads]) } channels[0].put(n) fmt.Println(<-res) }
Thu, 13 Jun 2013 22:08:54 GMT MAKE: /usr/local/src/go/bin/go build -o threadring.go-5.go_run 0.29s to complete and log all make actions COMMAND LINE: ./threadring.go-5.go_run 50000000 PROGRAM OUTPUT: 292