diff --git a/README.md b/README.md index e8db9a7..42e4709 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ a golang performence testing platform ## demo client ```go - perfm := perfm.New(perfm.NewConfig()) + perfm := perfm.New(perfm.WithParallel(5)) perfm.Registe(func() error { _, err := http.Get("http://www.baidu.com") return err diff --git a/config.go b/config.go index 2480262..2050851 100644 --- a/config.go +++ b/config.go @@ -16,7 +16,7 @@ type Config struct { } //NewConfig gen the config -func NewConfig(options ...Options) Config { +func newConfig(options ...Options) Config { c := Config{10, 4, 0, false, 1, 6553500, 15, 1.4, 1000000, 1000} for _, o := range options { o(&c) diff --git a/demo/main.go b/demo/main.go index 8fa7676..e4e0bf5 100644 --- a/demo/main.go +++ b/demo/main.go @@ -7,10 +7,8 @@ import ( ) func main() { - conf := perfm.NewConfig(perfm.WithBinsNumber(15), perfm.WithMinValue(0), - perfm.WithGrowthFactor(0.4), perfm.WithBaseBucketSize(20), perfm.WithParallel(5)) - perfm := perfm.New(conf) + perfm := perfm.New(perfm.WithBinsNumber(15), perfm.WithMinValue(0), perfm.WithGrowthFactor(0.4), perfm.WithBaseBucketSize(20), perfm.WithParallel(5)) perfm.Registe(func() error { _, err := http.Get("http://www.baidu.com") diff --git a/perfm.go b/perfm.go index 1796060..7d69b7e 100644 --- a/perfm.go +++ b/perfm.go @@ -41,7 +41,9 @@ type perfmonitor struct { } //New gengrate the perfm monitor -func New(conf Config) PerfMonitor { +func New(options ...Options) PerfMonitor { + conf := newConfig(options...) + histopt := hist.HistogramOptions{ NumBuckets: conf.BinsNumber, GrowthFactor: conf.GrowthFactor,