Skip to content

Commit 2f265c6

Browse files
committed
remove profiling stuff - easy to do via command line or IDE
Signed-off-by: Tim Bray <[email protected]>
1 parent ba69bce commit 2f265c6

File tree

4 files changed

+6
-91
lines changed

4 files changed

+6
-91
lines changed

internal/config.go

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ import (
99
)
1010

1111
type Config struct {
12-
Size int
13-
Fields []uint
14-
Fname string
15-
Filter Filters
16-
Width int
17-
Sample bool
18-
CPUProfile string
19-
TraceFname string
12+
Size int
13+
Fields []uint
14+
Fname string
15+
Filter Filters
16+
Width int
17+
Sample bool
2018
}
2119

2220
func Configure(args []string) (*Config, error) {
@@ -45,26 +43,6 @@ func Configure(args []string) (*Config, error) {
4543
i++
4644
config.Fields, err = parseFields(args[i])
4745
}
48-
case arg == "--cpuprofile":
49-
if (i + 1) >= len(args) {
50-
err = errors.New("insufficient arguments for --cpuprofile")
51-
} else {
52-
/* == ENABLE PROFILING ==
53-
i++
54-
config.CPUProfile = args[i]
55-
*/
56-
err = errors.New("to enable profiling, uncomment lines marked ENABLE PROFILING")
57-
}
58-
case arg == "--trace":
59-
if (i + 1) >= len(args) {
60-
err = errors.New("insufficient arguments for --trace")
61-
} else {
62-
/* == ENABLE PROFILING ==
63-
i++
64-
config.TraceFname = args[i]
65-
*/
66-
err = errors.New("to enable profiling, uncomment lines marked ENABLE PROFILING")
67-
}
6846
case arg == "-g" || arg == "--grep":
6947
if (i + 1) >= len(args) {
7048
err = errors.New("insufficient arguments for --grep")

internal/config_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ func TestArgSyntax(t *testing.T) {
1414
{"--sample", "--trace"}, {"--trace"},
1515
{"--sed"}, {"-s", "x"}, {"--sample", "--sed", "1"},
1616
{"--width", "a"}, {"-w", "0"}, {"--sample", "-w"},
17-
// COMMENT OUT FOLLOWING TO ENABLE TRACING
18-
{"--cpuprofile", "/tmp/cp"},
19-
{"--trace", "/tmp/tr"},
2017
}
2118

2219
// not testing -h/--help because it'd be extra work to avoid printing out the usage
@@ -29,10 +26,6 @@ func TestArgSyntax(t *testing.T) {
2926
{"--sample"},
3027
{"--width", "2"}, {"-w", "3"},
3128
{"--sample", "fname"},
32-
/* == ENABLE PROFILING ==
33-
{"--cpuprofile", "/tmp/cp"},
34-
{"--trace", "/tmp/tr"},
35-
*/
3629
}
3730

3831
for _, bad := range bads {

internal/runner.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,6 @@ func Run(config *Config, instream io.Reader) ([]*KeyCount, error) {
1212
var topList []*KeyCount
1313
var err error
1414

15-
/* == ENABLE PROFILING ==
16-
if config.CPUProfile != "" {
17-
f, err := os.Create(config.CPUProfile)
18-
if err != nil {
19-
_, _ = fmt.Fprintf(os.Stderr, "can't create profiler: %s\n", err.Error())
20-
return nil, err
21-
}
22-
err = pprof.StartCPUProfile(f)
23-
if err != nil {
24-
_, _ = fmt.Fprintf(os.Stderr, "can't start profiler: %s\n", err.Error())
25-
return nil, err
26-
}
27-
defer pprof.StopCPUProfile()
28-
}
29-
if config.TraceFname != "" {
30-
f, err := os.Create(config.TraceFname)
31-
if err != nil {
32-
_, _ = fmt.Fprintf(os.Stderr, "can't create trace output file: %s\n", err.Error())
33-
return nil, err
34-
}
35-
// The generated trace can be analyzed with: go tool trace <tracefile>
36-
err = trace.Start(f)
37-
if err != nil {
38-
_, _ = fmt.Fprintf(os.Stderr, "can't start tracing: %s\n", err.Error())
39-
return nil, err
40-
}
41-
defer trace.Stop()
42-
}
43-
*/
44-
4515
if config.Fname == "" {
4616
if config.Sample {
4717
for i, sed := range config.Filter.Seds {

internal/runner_test.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,6 @@ import (
55
"testing"
66
)
77

8-
/* == ENABLE PROFILING ==
9-
func TestRunner(t *testing.T) {
10-
var err error
11-
var c *Config
12-
13-
bads := [][]string{
14-
15-
{"--cpuprofile", "/"},
16-
{"--trace", "/"},
17-
}
18-
19-
for _, bad := range bads {
20-
osBad := []string{"OS"}
21-
osBad = append(osBad, bad...)
22-
c, err = Configure(osBad)
23-
if err != nil {
24-
t.Error("Configure!")
25-
}
26-
_, err = Run(c, nil)
27-
if err == nil {
28-
t.Error("Accepted bogus config")
29-
}
30-
}
31-
}
32-
*/
33-
348
func TestStreamAndFile(t *testing.T) {
359
args := []string{"-f", "7", "../test/data/apache-50k.txt"}
3610

0 commit comments

Comments
 (0)