@@ -13,10 +13,11 @@ import (
1313)
1414
1515func TestHeapReject (t * testing.T ) {
16- dh := pprof.DeltaHeapProfiler {}
16+ dh := new (pprof.DeltaHeapProfiler )
17+ opt := new (pprof.ProfileBuilderOptions )
1718 fs := generateMemProfileRecords (512 , 32 , 239 )
1819 p1 := bytes .NewBuffer (nil )
19- err := dh . WriteHeapProto (p1 , fs , int64 (runtime .MemProfileRate ), "" )
20+ err := WriteHeapProto (dh , opt , p1 , fs , int64 (runtime .MemProfileRate ))
2021 assert .NoError (t , err )
2122 p1Size := p1 .Len ()
2223 profile , err := gprofile .Parse (p1 )
@@ -27,7 +28,7 @@ func TestHeapReject(t *testing.T) {
2728 t .Log ("p1 size" , p1Size )
2829
2930 p2 := bytes .NewBuffer (nil )
30- err = dh . WriteHeapProto (p2 , fs , int64 (runtime .MemProfileRate ), "" )
31+ err = WriteHeapProto (dh , opt , p2 , fs , int64 (runtime .MemProfileRate ))
3132 assert .NoError (t , err )
3233 p2Size := p2 .Len ()
3334 assert .Less (t , p2Size , 1000 )
@@ -40,16 +41,15 @@ func TestHeapReject(t *testing.T) {
4041}
4142
4243func BenchmarkHeapRejectOrder (b * testing.B ) {
43- dh := pprof.DeltaHeapProfiler {
44- Options : pprof.ProfileBuilderOptions {
45- GenericsFrames : false ,
46- LazyMapping : true ,
47- },
44+ opt := & pprof.ProfileBuilderOptions {
45+ GenericsFrames : false ,
46+ LazyMapping : true ,
4847 }
48+ dh := & pprof.DeltaHeapProfiler {}
4949 fs := generateMemProfileRecords (512 , 32 , 239 )
5050 b .ResetTimer ()
5151 for i := 0 ; i < b .N ; i ++ {
52- dh . WriteHeapProto (io .Discard , fs , int64 (runtime .MemProfileRate ), "" )
52+ WriteHeapProto (dh , opt , io .Discard , fs , int64 (runtime .MemProfileRate ))
5353 }
5454}
5555
@@ -69,10 +69,11 @@ func TestMutexReject(t *testing.T) {
6969 runtime .SetMutexProfileFraction (5 )
7070 defer runtime .SetMutexProfileFraction (prevMutexProfileFraction )
7171
72- dh := pprof.DeltaMutexProfiler {}
72+ dh := new (pprof.DeltaMutexProfiler )
73+ opt := new (pprof.ProfileBuilderOptions )
7374 fs := generateBlockProfileRecords (512 , 32 , 239 )
7475 p1 := bytes .NewBuffer (nil )
75- err := dh . PrintCountCycleProfile (p1 , "contentions" , "delay" , scaler , fs )
76+ err := PrintCountCycleProfile (dh , opt , p1 , scaler , fs )
7677 assert .NoError (t , err )
7778 p1Size := p1 .Len ()
7879 profile , err := gprofile .Parse (p1 )
@@ -83,7 +84,7 @@ func TestMutexReject(t *testing.T) {
8384 t .Log ("p1 size" , p1Size )
8485
8586 p2 := bytes .NewBuffer (nil )
86- err = dh . PrintCountCycleProfile (p2 , "contentions" , "delay" , scaler , fs )
87+ err = PrintCountCycleProfile (dh , opt , p2 , scaler , fs )
8788 assert .NoError (t , err )
8889 p2Size := p2 .Len ()
8990 assert .Less (t , p2Size , 1000 )
@@ -107,18 +108,16 @@ func BenchmarkMutexRejectOrder(b *testing.B) {
107108 prevMutexProfileFraction := runtime .SetMutexProfileFraction (- 1 )
108109 runtime .SetMutexProfileFraction (5 )
109110 defer runtime .SetMutexProfileFraction (prevMutexProfileFraction )
110-
111- dh := pprof.DeltaMutexProfiler {
112- Options : pprof.ProfileBuilderOptions {
113- GenericsFrames : false ,
114- LazyMapping : true ,
115- },
111+ opt := & pprof.ProfileBuilderOptions {
112+ GenericsFrames : false ,
113+ LazyMapping : true ,
116114 }
115+ dh := & pprof.DeltaMutexProfiler {}
117116 fs := generateBlockProfileRecords (512 , 32 , 239 )
118117 b .ResetTimer ()
119118
120119 for i := 0 ; i < b .N ; i ++ {
121- dh . PrintCountCycleProfile (io . Discard , "contentions" , "delay" , scaler , fs )
120+ PrintCountCycleProfile (dh , opt , io . Discard , scaler , fs )
122121 }
123122 })
124123
0 commit comments