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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [runtime/] [gc_test.go] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2011 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package runtime_test
6
 
7
import (
8
        "runtime"
9
        "testing"
10
)
11
 
12
func TestGcSys(t *testing.T) {
13
        memstats := new(runtime.MemStats)
14
        runtime.GC()
15
        runtime.ReadMemStats(memstats)
16
        sys := memstats.Sys
17
 
18
        for i := 0; i < 1000000; i++ {
19
                workthegc()
20
        }
21
 
22
        // Should only be using a few MB.
23
        runtime.ReadMemStats(memstats)
24
        if sys > memstats.Sys {
25
                sys = 0
26
        } else {
27
                sys = memstats.Sys - sys
28
        }
29
        t.Logf("used %d extra bytes", sys)
30
        if sys > 4<<20 {
31
                t.Fatalf("using too much memory: %d bytes", sys)
32
        }
33
}
34
 
35
func workthegc() []byte {
36
        return make([]byte, 1029)
37
}

powered by: WebSVN 2.1.0

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