Skip to content

Commit

Permalink
comment out profiling code, cause those arguments to print instructions
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Bray <tbray@textuality.com>
  • Loading branch information
timbray committed Apr 11, 2024
1 parent 579b850 commit 0dde3fa
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions internal/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions internal/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions internal/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"fmt"
"io"
"os"
"runtime/pprof"
"runtime/trace"
)

func Run(config *Config, instream io.Reader) ([]*KeyCount, error) {
Expand All @@ -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())
Expand All @@ -43,6 +40,7 @@ func Run(config *Config, instream io.Reader) ([]*KeyCount, error) {
}
defer trace.Stop()
}
*/

if config.Fname == "" {
if config.Sample {
Expand Down
3 changes: 3 additions & 0 deletions internal/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (
"testing"
)

/* == ENABLE PROFILING ==
func TestRunner(t *testing.T) {
var err error
var c *Config
bads := [][]string{
{"--cpuprofile", "/"},
{"--trace", "/"},
}
Expand All @@ -27,6 +29,7 @@ func TestRunner(t *testing.T) {
}
}
}
*/

func TestStreamAndFile(t *testing.T) {
args := []string{"-f", "7", "../test/data/apache-50k.txt"}
Expand Down

0 comments on commit 0dde3fa

Please sign in to comment.