From: Jaana Burcu Dogan Date: Thu, 8 Sep 2016 18:21:20 +0000 (-0700) Subject: cmd/go: organize test profiling flags into their own sub-section X-Git-Tag: go1.8beta1~1407 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7b269195d30195f29080e17114aeec7821851870;p=gostls13.git cmd/go: organize test profiling flags into their own sub-section Fixes #17020. Change-Id: Ice21bd8eb4dbc208f244b275c3be604bc8e3efe7 Reviewed-on: https://go-review.googlesource.com/28783 Reviewed-by: Rob Pike Run-TryBot: Jaana Burcu Dogan --- diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 16c0028f77..1ff04f8206 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1380,28 +1380,11 @@ // By default, no benchmarks run. To run all benchmarks, // use '-bench .' or '-bench=.'. // -// -benchmem -// Print memory allocation statistics for benchmarks. -// // -benchtime t // Run enough iterations of each benchmark to take t, specified // as a time.Duration (for example, -benchtime 1h30s). // The default is 1 second (1s). // -// -blockprofile block.out -// Write a goroutine blocking profile to the specified file -// when all tests are complete. -// Writes test binary as -c would. -// -// -blockprofilerate n -// Control the detail provided in goroutine blocking profiles by -// calling runtime.SetBlockProfileRate with n. -// See 'go doc runtime.SetBlockProfileRate'. -// The profiler aims to sample, on average, one blocking event every -// n nanoseconds the program spends blocked. By default, -// if -test.blockprofile is set without this flag, all blocking events -// are recorded, equivalent to -test.blockprofilerate=1. -// // -count n // Run each test and benchmark n times (default 1). // If -cpu is set, run n times for each GOMAXPROCS value. @@ -1427,33 +1410,11 @@ // Packages are specified as import paths. // Sets -cover. // -// -coverprofile cover.out -// Write a coverage profile to the file after all tests have passed. -// Sets -cover. -// // -cpu 1,2,4 // Specify a list of GOMAXPROCS values for which the tests or // benchmarks should be executed. The default is the current value // of GOMAXPROCS. // -// -cpuprofile cpu.out -// Write a CPU profile to the specified file before exiting. -// Writes test binary as -c would. -// -// -memprofile mem.out -// Write a memory profile to the file after all tests have passed. -// Writes test binary as -c would. -// -// -memprofilerate n -// Enable more precise (and expensive) memory profiles by setting -// runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. -// To profile all memory allocations, use -test.memprofilerate=1 -// and pass --alloc_space flag to the pprof tool. -// -// -outputdir directory -// Place output files from profiling in the specified directory, -// by default the directory in which "go test" is running. -// // -parallel n // Allow parallel execution of test functions that call t.Parallel. // The value of this flag is the maximum number of tests to run @@ -1479,13 +1440,55 @@ // If a test runs longer than t, panic. // The default is 10 minutes (10m). // -// -trace trace.out -// Write an execution trace to the specified file before exiting. -// // -v // Verbose output: log all tests as they are run. Also print all // text from Log and Logf calls even if the test succeeds. // +// The following flags are also recognized by 'go test' and can be used to +// profile the tests during execution:: +// +// -benchmem +// Print memory allocation statistics for benchmarks. +// +// -blockprofile block.out +// Write a goroutine blocking profile to the specified file +// when all tests are complete. +// Writes test binary as -c would. +// +// -blockprofilerate n +// Control the detail provided in goroutine blocking profiles by +// calling runtime.SetBlockProfileRate with n. +// See 'go doc runtime.SetBlockProfileRate'. +// The profiler aims to sample, on average, one blocking event every +// n nanoseconds the program spends blocked. By default, +// if -test.blockprofile is set without this flag, all blocking events +// are recorded, equivalent to -test.blockprofilerate=1. +// +// -coverprofile cover.out +// Write a coverage profile to the file after all tests have passed. +// Sets -cover. +// +// -cpuprofile cpu.out +// Write a CPU profile to the specified file before exiting. +// Writes test binary as -c would. +// +// -memprofile mem.out +// Write a memory profile to the file after all tests have passed. +// Writes test binary as -c would. +// +// -memprofilerate n +// Enable more precise (and expensive) memory profiles by setting +// runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. +// To profile all memory allocations, use -test.memprofilerate=1 +// and pass --alloc_space flag to the pprof tool. +// +// -outputdir directory +// Place output files from profiling in the specified directory, +// by default the directory in which "go test" is running. +// +// -trace trace.out +// Write an execution trace to the specified file before exiting. +// // Each of these flags is also recognized with an optional 'test.' prefix, // as in -test.v. When invoking the generated test binary (the result of // 'go test -c') directly, however, the prefix is mandatory. diff --git a/src/cmd/go/test.go b/src/cmd/go/test.go index e1527da255..138d46c381 100644 --- a/src/cmd/go/test.go +++ b/src/cmd/go/test.go @@ -135,28 +135,11 @@ const testFlag2 = ` By default, no benchmarks run. To run all benchmarks, use '-bench .' or '-bench=.'. - -benchmem - Print memory allocation statistics for benchmarks. - -benchtime t Run enough iterations of each benchmark to take t, specified as a time.Duration (for example, -benchtime 1h30s). The default is 1 second (1s). - -blockprofile block.out - Write a goroutine blocking profile to the specified file - when all tests are complete. - Writes test binary as -c would. - - -blockprofilerate n - Control the detail provided in goroutine blocking profiles by - calling runtime.SetBlockProfileRate with n. - See 'go doc runtime.SetBlockProfileRate'. - The profiler aims to sample, on average, one blocking event every - n nanoseconds the program spends blocked. By default, - if -test.blockprofile is set without this flag, all blocking events - are recorded, equivalent to -test.blockprofilerate=1. - -count n Run each test and benchmark n times (default 1). If -cpu is set, run n times for each GOMAXPROCS value. @@ -182,33 +165,11 @@ const testFlag2 = ` Packages are specified as import paths. Sets -cover. - -coverprofile cover.out - Write a coverage profile to the file after all tests have passed. - Sets -cover. - -cpu 1,2,4 Specify a list of GOMAXPROCS values for which the tests or benchmarks should be executed. The default is the current value of GOMAXPROCS. - -cpuprofile cpu.out - Write a CPU profile to the specified file before exiting. - Writes test binary as -c would. - - -memprofile mem.out - Write a memory profile to the file after all tests have passed. - Writes test binary as -c would. - - -memprofilerate n - Enable more precise (and expensive) memory profiles by setting - runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. - To profile all memory allocations, use -test.memprofilerate=1 - and pass --alloc_space flag to the pprof tool. - - -outputdir directory - Place output files from profiling in the specified directory, - by default the directory in which "go test" is running. - -parallel n Allow parallel execution of test functions that call t.Parallel. The value of this flag is the maximum number of tests to run @@ -234,13 +195,55 @@ const testFlag2 = ` If a test runs longer than t, panic. The default is 10 minutes (10m). - -trace trace.out - Write an execution trace to the specified file before exiting. - -v Verbose output: log all tests as they are run. Also print all text from Log and Logf calls even if the test succeeds. +The following flags are also recognized by 'go test' and can be used to +profile the tests during execution:: + + -benchmem + Print memory allocation statistics for benchmarks. + + -blockprofile block.out + Write a goroutine blocking profile to the specified file + when all tests are complete. + Writes test binary as -c would. + + -blockprofilerate n + Control the detail provided in goroutine blocking profiles by + calling runtime.SetBlockProfileRate with n. + See 'go doc runtime.SetBlockProfileRate'. + The profiler aims to sample, on average, one blocking event every + n nanoseconds the program spends blocked. By default, + if -test.blockprofile is set without this flag, all blocking events + are recorded, equivalent to -test.blockprofilerate=1. + + -coverprofile cover.out + Write a coverage profile to the file after all tests have passed. + Sets -cover. + + -cpuprofile cpu.out + Write a CPU profile to the specified file before exiting. + Writes test binary as -c would. + + -memprofile mem.out + Write a memory profile to the file after all tests have passed. + Writes test binary as -c would. + + -memprofilerate n + Enable more precise (and expensive) memory profiles by setting + runtime.MemProfileRate. See 'go doc runtime.MemProfileRate'. + To profile all memory allocations, use -test.memprofilerate=1 + and pass --alloc_space flag to the pprof tool. + + -outputdir directory + Place output files from profiling in the specified directory, + by default the directory in which "go test" is running. + + -trace trace.out + Write an execution trace to the specified file before exiting. + Each of these flags is also recognized with an optional 'test.' prefix, as in -test.v. When invoking the generated test binary (the result of 'go test -c') directly, however, the prefix is mandatory.