Skip to content

Commit

Permalink
Added --silent option for support
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlemoine committed Mar 1, 2017
1 parent 2d76afb commit 25a4a8a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/booster.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var boosterCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
writeLogBooster()
rand.Seed(boosterSeed)
t, err := support.Booster(supportIntree, supportBoottrees, supportLog, boosterEmpirical, rootCpus)
t, err := support.Booster(supportIntree, supportBoottrees, supportLog, supportSilent, boosterEmpirical, rootCpus)
if err != nil {
io.ExitWithMessage(err)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/classical.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
writeLogClassical()
t, e := support.Classical(supportIntree, supportBoottrees, rootCpus)
if e != nil {
io.ExitWithMessage(e)
Expand Down
2 changes: 2 additions & 0 deletions cmd/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var supportOutFile string
var supportLogFile string
var supportOut *os.File
var supportLog *os.File
var supportSilent bool

// supportCmd represents the support command
var supportCmd = &cobra.Command{
Expand Down Expand Up @@ -57,4 +58,5 @@ func init() {
supportCmd.PersistentFlags().StringVarP(&supportBoottrees, "bootstrap", "b", "none", "Bootstrap trees input file")
supportCmd.PersistentFlags().StringVarP(&supportOutFile, "out", "o", "stdout", "Output tree file, with supports")
supportCmd.PersistentFlags().StringVarP(&supportLogFile, "log-file", "l", "stderr", "Output log file")
supportCmd.PersistentFlags().BoolVar(&supportSilent, "silent", false, "If true, progress messages will not be printed to stderr")
}
11 changes: 8 additions & 3 deletions support/booster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type BoosterSupporter struct {
currentTree int
mutex *sync.Mutex
stop bool
silent bool
}

func (supporter *BoosterSupporter) ExpectedRandValues(depth int) float64 {
Expand Down Expand Up @@ -246,7 +247,9 @@ func (supporter *BoosterSupporter) ComputeValue(refTree *tree.Tree, empiricalTre
var nb_branches_close int
for treeV := range bootTreeChannel {
nb_branches_close = 0
fmt.Fprintf(os.Stderr, "CPU : %d - Bootstrap tree %d\n", cpu, treeV.Id)
if !supporter.silent {
fmt.Fprintf(os.Stderr, "CPU : %d - Bootstrap tree %d\n", cpu, treeV.Id)
}
bootEdges := treeV.Tree.Edges()

for i, _ := range edges {
Expand Down Expand Up @@ -329,12 +332,14 @@ func (supporter *BoosterSupporter) ComputeValue(refTree *tree.Tree, empiricalTre
return nil
}

func Booster(reftreefile, boottreefile string, logfile *os.File, empirical bool, cpus int) (*tree.Tree, error) {
func Booster(reftreefile, boottreefile string, logfile *os.File, silent bool, empirical bool, cpus int) (*tree.Tree, error) {
var supporter *BoosterSupporter = &BoosterSupporter{}
supporter.silent = silent
return ComputeSupport(reftreefile, boottreefile, logfile, empirical, cpus, supporter)
}
func BoosterFile(reftreefile, boottreefile *bufio.Reader, logfile *os.File, empirical bool, cpus int) (*tree.Tree, error) {
func BoosterFile(reftreefile, boottreefile *bufio.Reader, logfile *os.File, silent bool, empirical bool, cpus int) (*tree.Tree, error) {
var supporter *BoosterSupporter = &BoosterSupporter{}
supporter.silent = silent
return ComputeSupportFile(reftreefile, boottreefile, logfile, empirical, cpus, supporter)
}

Expand Down

0 comments on commit 25a4a8a

Please sign in to comment.