Debian Codegraph @

benchmarks/live_heap_test.go

raw
1 package benchmark
2
3 import (
4 "os"
5 "strconv"
6 )
7
8 // liveHeap is the live heap of the program which the benchmarks run in, when BENCH_LIVE_HEAP_MB sets its size in
9 // megabytes. A program which decodes JSON has a live heap of its own, which sets the goal of the GC for every
10 // library alike, as GOGC makes the goal twice the live heap. Without it, the goal is set by what a library itself
11 // keeps alive, as its caches and pools: a library which keeps more is collected less often in a benchmark, which
12 // a real program doesn't see. The benchmarks are compared with and without it.
13 var liveHeap []byte
14
15 func init() {
16 if mb, err := strconv.Atoi(os.Getenv("BENCH_LIVE_HEAP_MB")); err == nil && mb > 0 {
17 liveHeap = make([]byte, mb<<20)
18 }
19 }