repo_description: Continuous Profiling Platform. Debug performance issues down to a single line of code
repo_topics: continuous-profiling developer-tools devops find-bottlenecks golang hacktoberfest linux monitoring observability performance profiling pyroscope python ruby
code: package compactor
  
  import (
  	"strings"
  	"time"
  )
  
  // DurationList is the block ranges for a tsdb
  type DurationList []time.Duration
  
  // String implements the flag.Value interface
  func (d *DurationList) String() string {
  	values := make([]string, 0, len(*d))
  	for _, v := range *d {
  		values = append(values, v.String())
  	}
  
  	return strings.Join(values, ",")
  }
  
  // Set implements the flag.Value interface
  func (d *DurationList) Set(s string) error {
  	values := strings.Split(s, ",")
  	*d = make([]time.Duration, 0, len(values)) // flag.Parse may be called twice, so overwrite instead of append
  	for _, v := range values {
  		t, err := time.ParseDuration(v)
  		if err != nil {
  			return err
  		}
  		*d = append(*d, t)
  	}
  	return nil
  }
  
  // ToMilliseconds returns the duration list in milliseconds
  func (d *DurationList) ToMilliseconds() []int64 {
  	values := make([]int64, 0, len(*d))
  	for _, t := range *d {
  		values = append(values, t.Milliseconds())
  	}
  
  	return values
  }
  