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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [bench/] [garbage/] [stats.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// Copyright 2010 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 main
6
 
7
import (
8
        "fmt"
9
        "runtime"
10
        "sort"
11
        "time"
12
)
13
 
14
func gcstats(name string, n int, t time.Duration) {
15
        st := &runtime.MemStats
16
        fmt.Printf("garbage.%sMem Alloc=%d/%d Heap=%d NextGC=%d Mallocs=%d\n", name, st.Alloc, st.TotalAlloc, st.Sys, st.NextGC, st.Mallocs)
17
        fmt.Printf("garbage.%s %d %d ns/op\n", name, n, t.Nanoseconds()/int64(n))
18
        fmt.Printf("garbage.%sLastPause 1 %d ns/op\n", name, st.PauseNs[(st.NumGC-1)%uint32(len(st.PauseNs))])
19
        fmt.Printf("garbage.%sPause %d %d ns/op\n", name, st.NumGC, int64(st.PauseTotalNs)/int64(st.NumGC))
20
        nn := int(st.NumGC)
21
        if nn >= len(st.PauseNs) {
22
                nn = len(st.PauseNs)
23
        }
24
        t1, t2, t3, t4, t5 := tukey5(st.PauseNs[0:nn])
25
        fmt.Printf("garbage.%sPause5: %d %d %d %d %d\n", name, t1, t2, t3, t4, t5)
26
 
27
        //      fmt.Printf("garbage.%sScan: %v\n", name, st.ScanDist)
28
}
29
 
30
type T []uint64
31
 
32
func (t T) Len() int           { return len(t) }
33
func (t T) Swap(i, j int)      { t[i], t[j] = t[j], t[i] }
34
func (t T) Less(i, j int) bool { return t[i] < t[j] }
35
 
36
func tukey5(raw []uint64) (lo, q1, q2, q3, hi uint64) {
37
        x := make(T, len(raw))
38
        copy(x, raw)
39
        sort.Sort(T(x))
40
        lo = x[0]
41
        q1 = x[len(x)/4]
42
        q2 = x[len(x)/2]
43
        q3 = x[len(x)*3/4]
44
        hi = x[len(x)-1]
45
        return
46
}

powered by: WebSVN 2.1.0

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