diff --git a/internal/config.go b/internal/config.go index cbce4af..b6c0048 100644 --- a/internal/config.go +++ b/internal/config.go @@ -49,15 +49,21 @@ func Configure(args []string) (*Config, error) { if (i + 1) >= len(args) { err = errors.New("insufficient arguments for --cpuprofile") } else { + /* == ENABLE PROFILING == i++ config.CPUProfile = args[i] + */ + err = errors.New("to enable profiling, uncomment lines marked ENABLE PROFILING") } case arg == "--trace": if (i + 1) >= len(args) { err = errors.New("insufficient arguments for --trace") } else { + /* == ENABLE PROFILING == i++ config.TraceFname = args[i] + */ + err = errors.New("to enable profiling, uncomment lines marked ENABLE PROFILING") } case arg == "-g" || arg == "--grep": if (i + 1) >= len(args) { diff --git a/internal/config_test.go b/internal/config_test.go index 8d54137..25cd73a 100644 --- a/internal/config_test.go +++ b/internal/config_test.go @@ -26,8 +26,10 @@ func TestArgSyntax(t *testing.T) { {"--sample"}, {"--width", "2"}, {"-w", "3"}, {"--sample", "fname"}, + /* == ENABLE PROFILING == {"--cpuprofile", "/tmp/cp"}, {"--trace", "/tmp/tr"}, + */ } for _, bad := range bads { diff --git a/internal/runner.go b/internal/runner.go index d4ef691..d52c8c6 100644 --- a/internal/runner.go +++ b/internal/runner.go @@ -4,8 +4,6 @@ import ( "fmt" "io" "os" - "runtime/pprof" - "runtime/trace" ) func Run(config *Config, instream io.Reader) ([]*KeyCount, error) { @@ -14,9 +12,8 @@ func Run(config *Config, instream io.Reader) ([]*KeyCount, error) { var topList []*KeyCount var err error - // TODO: Figure out how to make some of these things fail to improve test coverage. - // Alternately, just comment out the tracing stuff. - if config.CPUProfile != "" { + /* == ENABLE PROFILING == + if config.CPUProfile != "" { f, err := os.Create(config.CPUProfile) if err != nil { _, _ = fmt.Fprintf(os.Stderr, "can't create profiler: %s\n", err.Error()) @@ -43,6 +40,7 @@ func Run(config *Config, instream io.Reader) ([]*KeyCount, error) { } defer trace.Stop() } + */ if config.Fname == "" { if config.Sample { diff --git a/internal/runner_test.go b/internal/runner_test.go index a77e7c5..659a3db 100644 --- a/internal/runner_test.go +++ b/internal/runner_test.go @@ -5,11 +5,13 @@ import ( "testing" ) +/* == ENABLE PROFILING == func TestRunner(t *testing.T) { var err error var c *Config bads := [][]string{ + {"--cpuprofile", "/"}, {"--trace", "/"}, } @@ -27,6 +29,7 @@ func TestRunner(t *testing.T) { } } } +*/ func TestStreamAndFile(t *testing.T) { args := []string{"-f", "7", "../test/data/apache-50k.txt"}