github.com/shuguocloud/go-zero@v1.3.0/core/proc/profile_test.go (about) 1 package proc 2 3 import ( 4 "log" 5 "strings" 6 "testing" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestProfile(t *testing.T) { 12 var buf strings.Builder 13 log.SetOutput(&buf) 14 profiler := StartProfile() 15 // start again should not work 16 assert.NotNil(t, StartProfile()) 17 profiler.Stop() 18 // stop twice 19 profiler.Stop() 20 assert.True(t, strings.Contains(buf.String(), ".pprof")) 21 }