-
Notifications
You must be signed in to change notification settings - Fork 0
/
smallheap.go
45 lines (36 loc) · 824 Bytes
/
smallheap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2016 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.
// Test throughput with small stacks and high allocation rate.
//
// TODO: What metrics? Allocation rate?
package main
import (
"flag"
"os"
"runtime"
"time"
"github.com/aclements/go-gcbench/gcbench"
)
var sink []*byte
var flagDuration = flag.Duration("benchtime", 10*time.Second, "steady state duration")
func main() {
flag.Parse()
if flag.NArg() > 0 {
flag.Usage()
os.Exit(2)
}
gcbench.NewBenchmark("SmallHeap", benchMain).Run()
}
func benchMain() {
sink = make([]*byte, 4*runtime.GOMAXPROCS(-1))
for i := range sink {
go func(i int) {
for {
sink[i] = &make([]byte, 64)[0]
}
}(i)
}
<-time.After(*flagDuration)
os.Exit(0)
}