package pprof
import (
)
func ( io.Writer, []runtime.MemProfileRecord, int64, string) error {
:= newProfileBuilder()
.pbValueType(tagProfile_PeriodType, "space", "bytes")
.pb.int64Opt(tagProfile_Period, )
.pbValueType(tagProfile_SampleType, "alloc_objects", "count")
.pbValueType(tagProfile_SampleType, "alloc_space", "bytes")
.pbValueType(tagProfile_SampleType, "inuse_objects", "count")
.pbValueType(tagProfile_SampleType, "inuse_space", "bytes")
if != "" {
.pb.int64Opt(tagProfile_DefaultSampleType, .stringIndex())
}
:= []int64{0, 0, 0, 0}
var []uint64
for , := range {
:= true
for := 0; < 2; ++ {
:= .Stack()
if {
for , := range {
if := runtime.FuncForPC(); != nil && strings.HasPrefix(.Name(), "runtime.") {
continue
}
= [:]
break
}
}
= .appendLocsForStack([:0], )
if len() > 0 {
break
}
= false
}
[0], [1] = scaleHeapSample(.AllocObjects, .AllocBytes, )
[2], [3] = scaleHeapSample(.InUseObjects(), .InUseBytes(), )
var int64
if .AllocObjects > 0 {
= .AllocBytes / .AllocObjects
}
.pbSample(, , func() {
if != 0 {
.pbLabel(tagSample_Label, "bytes", "", )
}
})
}
.build()
return nil
}
func (, , int64) (int64, int64) {
if == 0 || == 0 {
return 0, 0
}
if <= 1 {
return ,
}
:= float64() / float64()
:= 1 / (1 - math.Exp(-/float64()))
return int64(float64() * ), int64(float64() * )
}