-
Notifications
You must be signed in to change notification settings - Fork 21
/
perf.go
49 lines (37 loc) · 856 Bytes
/
perf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package command
import (
"flag"
"fmt"
"strings"
"github.com/funkygao/gocli"
)
type Perf struct {
Ui cli.Ui
Cmd string
}
func (this *Perf) Run(args []string) (exitCode int) {
var mode string
cmdFlags := flag.NewFlagSet("perf", flag.ContinueOnError)
cmdFlags.Usage = func() { this.Ui.Output(this.Help()) }
cmdFlags.StringVar(&mode, "mode", "io", "")
if err := cmdFlags.Parse(args); err != nil {
return 1
}
switch mode {
case "io":
this.Ui.Output(fmt.Sprintf("perf record -e block:block_rq_complete -a sleep 10"))
this.Ui.Output("perf script")
}
return
}
func (*Perf) Synopsis() string {
return "Probe system low level performance problems with perf"
}
func (this *Perf) Help() string {
help := fmt.Sprintf(`
Usage: %s perf [options]
%s
-mode io|cpu
`, this.Cmd, this.Synopsis())
return strings.TrimSpace(help)
}