• Russ Cox's avatar
    runtime/pprof: sort counted profiles by count · 6969d9bf
    Russ Cox authored
    This is especially helpful in programs with very large numbers of goroutines:
    the bulk of the goroutines will show up at the top.
    
    Before:
    	1 @ 0x86ab8 0x86893 0x82164 0x8e7ce 0x7b798 0x5b871
    	#	0x86ab8	runtime/pprof.writeRuntimeProfile+0xb8		/Users/rsc/go/src/runtime/pprof/pprof.go:545
    	#	0x86893	runtime/pprof.writeGoroutine+0x93		/Users/rsc/go/src/runtime/pprof/pprof.go:507
    	#	0x82164	runtime/pprof.(*Profile).WriteTo+0xd4		/Users/rsc/go/src/runtime/pprof/pprof.go:236
    	#	0x8e7ce	runtime/pprof_test.TestGoroutineCounts+0x15e	/Users/rsc/go/src/runtime/pprof/pprof_test.go:603
    	#	0x7b798	testing.tRunner+0x98				/Users/rsc/go/src/testing/testing.go:473
    
    	1 @ 0x2d373 0x2d434 0x560f 0x516b 0x7cd42 0x7b861 0x2297 0x2cf90 0x5b871
    	#	0x7cd42	testing.RunTests+0x8d2	/Users/rsc/go/src/testing/testing.go:583
    	#	0x7b861	testing.(*M).Run+0x81	/Users/rsc/go/src/testing/testing.go:515
    	#	0x2297	main.main+0x117		runtime/pprof/_test/_testmain.go:72
    	#	0x2cf90	runtime.main+0x2b0	/Users/rsc/go/src/runtime/proc.go:188
    
    	10 @ 0x2d373 0x2d434 0x560f 0x516b 0x8e5b6 0x5b871
    	#	0x8e5b6	runtime/pprof_test.func1+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:582
    
    	50 @ 0x2d373 0x2d434 0x560f 0x516b 0x8e656 0x5b871
    	#	0x8e656	runtime/pprof_test.func3+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:584
    
    	40 @ 0x2d373 0x2d434 0x560f 0x516b 0x8e606 0x5b871
    	#	0x8e606	runtime/pprof_test.func2+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:583
    
    After:
    
    	50 @ 0x2d373 0x2d434 0x560f 0x516b 0x8ecc6 0x5b871
    	#	0x8ecc6	runtime/pprof_test.func3+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:584
    
    	40 @ 0x2d373 0x2d434 0x560f 0x516b 0x8ec76 0x5b871
    	#	0x8ec76	runtime/pprof_test.func2+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:583
    
    	10 @ 0x2d373 0x2d434 0x560f 0x516b 0x8ec26 0x5b871
    	#	0x8ec26	runtime/pprof_test.func1+0x36	/Users/rsc/go/src/runtime/pprof/pprof_test.go:582
    
    	1 @ 0x2d373 0x2d434 0x560f 0x516b 0x7cd42 0x7b861 0x2297 0x2cf90 0x5b871
    	#	0x7cd42	testing.RunTests+0x8d2	/Users/rsc/go/src/testing/testing.go:583
    	#	0x7b861	testing.(*M).Run+0x81	/Users/rsc/go/src/testing/testing.go:515
    	#	0x2297	main.main+0x117		runtime/pprof/_test/_testmain.go:72
    	#	0x2cf90	runtime.main+0x2b0	/Users/rsc/go/src/runtime/proc.go:188
    
    	1 @ 0x87128 0x86f03 0x82164 0x8ee30 0x7b798 0x5b871
    	#	0x87128	runtime/pprof.writeRuntimeProfile+0xb8		/Users/rsc/go/src/runtime/pprof/pprof.go:566
    	#	0x86f03	runtime/pprof.writeGoroutine+0x93		/Users/rsc/go/src/runtime/pprof/pprof.go:528
    	#	0x82164	runtime/pprof.(*Profile).WriteTo+0xd4		/Users/rsc/go/src/runtime/pprof/pprof.go:236
    	#	0x8ee30	runtime/pprof_test.TestGoroutineCounts+0x150	/Users/rsc/go/src/runtime/pprof/pprof_test.go:603
    	#	0x7b798	testing.tRunner+0x98				/Users/rsc/go/src/testing/testing.go:473
    
    Change-Id: I43de9eee2d96f9c46f7b0fbe099a0571164324f5
    Reviewed-on: https://go-review.googlesource.com/20107Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    6969d9bf
pprof_test.go 16.3 KB