if data[0] != 3 || data[2] == 0 {
return fmt.Errorf("malformed profile")
}
- b.period = int64(data[2]) * 1000
+ // data[2] is sampling rate in Hz. Convert to sampling
+ // period in nanoseconds.
+ b.period = 1e9 / int64(data[2])
b.havePeriod = true
data = data[3:]
}
// A test server with mock cpu profile data.
var buf bytes.Buffer
- b := []uint64{3, 0, 2000} // empty profile with 2ms sample period
+ b := []uint64{3, 0, 500} // empty profile at 500 Hz (2ms sample period)
p, err := translateCPUProfile(b)
if err != nil {
t.Fatalf("translateCPUProfile: %v", err)
addr1, addr2, map1, map2 := testPCs(t)
b := []uint64{
- 3, 0, 2000, // periodMs = 2000
+ 3, 0, 500, // hz = 500
5, 0, 10, uint64(addr1), uint64(addr1 + 2), // 10 samples in addr1
5, 0, 40, uint64(addr2), uint64(addr2 + 2), // 40 samples in addr2
5, 0, 10, uint64(addr1), uint64(addr1 + 2), // 10 samples in addr1