URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [chan/] [select2.go] - Rev 700
Compare with Previous | Blame | View Log
// $G $D/$F.go && $L $F.$A && ./$A.out// Copyright 2010 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package mainimport "runtime"func sender(c chan int, n int) {for i := 0; i < n; i++ {c <- 1}}func receiver(c, dummy chan int, n int) {for i := 0; i < n; i++ {select {case <-c:// nothingcase <-dummy:panic("dummy")}}}func main() {runtime.MemProfileRate = 0c := make(chan int)dummy := make(chan int)// warm upgo sender(c, 100000)receiver(c, dummy, 100000)runtime.GC()memstats := new(runtime.MemStats)runtime.ReadMemStats(memstats)alloc := memstats.Alloc// second time shouldn't increase footprint by muchgo sender(c, 100000)receiver(c, dummy, 100000)runtime.GC()runtime.ReadMemStats(memstats)if memstats.Alloc-alloc > 1e5 {println("BUG: too much memory for 100,000 selects:", memstats.Alloc-alloc)}}
