OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [init1.go] - Blame information for rev 858

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// $G $D/$F.go && $L $F.$A && ./$A.out
2
 
3
// Copyright 2011 The Go Authors.  All rights reserved.
4
// Use of this source code is governed by a BSD-style
5
// license that can be found in the LICENSE file.
6
 
7
// Test that goroutines and garbage collection run during init.
8
 
9
package main
10
 
11
import "runtime"
12
 
13
var x []byte
14
 
15
func init() {
16
        c := make(chan int)
17
        go send(c)
18
        <-c
19
 
20
        const chunk = 1<<20
21
        runtime.UpdateMemStats()
22
        sys := runtime.MemStats.Sys
23
        b := make([]byte, chunk)
24
        for i := range b {
25
                b[i] = byte(i%10 + '0')
26
        }
27
        s := string(b)
28
        for i := 0; i < 1000; i++ {
29
                x = []byte(s)
30
        }
31
        runtime.UpdateMemStats()
32
        sys1 := runtime.MemStats.Sys
33
        if sys1-sys > chunk*50 {
34
                println("allocated 1000 chunks of", chunk, "and used ", sys1-sys, "memory")
35
        }
36
}
37
 
38
func send(c chan int) {
39
        c <- 1
40
}
41
 
42
func main() {
43
}
44
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.