mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 08:35:55 +00:00
Add -human flag to bagent
This commit is contained in:
parent
44a738afde
commit
8690157d3f
1 changed files with 13 additions and 4 deletions
|
|
@ -1112,6 +1112,8 @@ type BagentCommand struct {
|
|||
AgentNum int
|
||||
// Slice of pilosa hosts to run the Benchmarks against.
|
||||
Hosts []string
|
||||
// Enable pretty printing of results, for human consumption.
|
||||
HumanReadable bool
|
||||
|
||||
Stdin io.Reader
|
||||
Stdout io.Writer
|
||||
|
|
@ -1121,9 +1123,10 @@ type BagentCommand struct {
|
|||
// NewBagentCommand returns a new instance of BagentCommand.
|
||||
func NewBagentCommand(stdin io.Reader, stdout, stderr io.Writer) *BagentCommand {
|
||||
return &BagentCommand{
|
||||
Benchmarks: []bench.Benchmark{},
|
||||
Hosts: []string{},
|
||||
AgentNum: 0,
|
||||
Benchmarks: []bench.Benchmark{},
|
||||
Hosts: []string{},
|
||||
AgentNum: 0,
|
||||
HumanReadable: false,
|
||||
|
||||
Stdin: stdin,
|
||||
Stdout: stdout,
|
||||
|
|
@ -1144,6 +1147,7 @@ func (cmd *BagentCommand) ParseFlags(args []string) error {
|
|||
var pilosaHosts string
|
||||
fs.StringVar(&pilosaHosts, "hosts", "localhost:15000", "Comma separated list of host:port")
|
||||
fs.IntVar(&cmd.AgentNum, "agentNum", 0, "An integer differentiating this agent from other in the fleet.")
|
||||
fs.BoolVar(&cmd.HumanReadable, "human", false, "Boolean to enable human-readable format.")
|
||||
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
|
|
@ -1205,6 +1209,9 @@ The following arguments are available:
|
|||
-agentNum N
|
||||
An integer differentiating this agent from others in the fleet.
|
||||
|
||||
-human
|
||||
Boolean to enable human-readable format.
|
||||
|
||||
subcommands:
|
||||
diagonal-set-bits
|
||||
random-set-bits
|
||||
|
|
@ -1226,7 +1233,9 @@ func (cmd *BagentCommand) Run(ctx context.Context) error {
|
|||
res := sbm.Run(ctx, cmd.AgentNum)
|
||||
enc := json.NewEncoder(cmd.Stdout)
|
||||
enc.SetIndent("", " ")
|
||||
res = bench.Prettify(res)
|
||||
if cmd.HumanReadable {
|
||||
res = bench.Prettify(res)
|
||||
}
|
||||
err = enc.Encode(res)
|
||||
if err != nil {
|
||||
fmt.Fprintln(cmd.Stderr, err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue