From 63c4738591e838616da741db10e65286654657f8 Mon Sep 17 00:00:00 2001 From: Sujit D'Mello Date: Mon, 20 Jul 2020 19:59:52 -0400 Subject: [PATCH] Added options test and docs --- runner/options.go | 4 ++-- runner/options_test.go | 3 +++ runner/reporter.go | 4 ++-- www/docs/options.md | 6 +++++- www/docs/usage.md | 1 + 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/runner/options.go b/runner/options.go index 6814eced..f42fd57d 100644 --- a/runner/options.go +++ b/runner/options.go @@ -69,7 +69,7 @@ type RunConfig struct { name string cpus int tags []byte - skipFirst uint + skipFirst int } // Option controls some aspect of run @@ -455,7 +455,7 @@ func WithCPUs(c uint) Option { func WithSkipFirst(c uint) Option { return func(o *RunConfig) error { if c > 0 { - o.skipFirst = uint(c) + o.skipFirst = int(c) } return nil diff --git a/runner/options_test.go b/runner/options_test.go index 5ecd6028..ae73b166 100644 --- a/runner/options_test.go +++ b/runner/options_test.go @@ -48,6 +48,7 @@ func TestRunConfig_newRunConfig(t *testing.T) { assert.Equal(t, 50, c.c) assert.Equal(t, 0, c.qps) assert.Equal(t, false, c.binary) + assert.Equal(t, 0, c.skipFirst) assert.Equal(t, time.Duration(0), c.z) assert.Equal(t, time.Duration(0), c.keepaliveTime) assert.Equal(t, time.Duration(20*time.Second), c.timeout) @@ -70,6 +71,7 @@ func TestRunConfig_newRunConfig(t *testing.T) { WithTotalRequests(100), WithConcurrency(20), WithQPS(5), + WithSkipFirst(5), WithRunDuration(time.Duration(5*time.Minute)), WithKeepalive(time.Duration(60*time.Second)), WithTimeout(time.Duration(10*time.Second)), @@ -89,6 +91,7 @@ func TestRunConfig_newRunConfig(t *testing.T) { assert.Equal(t, 100, c.n) assert.Equal(t, 20, c.c) assert.Equal(t, 5, c.qps) + assert.Equal(t, int(5), c.skipFirst) assert.Equal(t, false, c.binary) assert.Equal(t, time.Duration(5*time.Minute), c.z) assert.Equal(t, time.Duration(60*time.Second), c.keepaliveTime) diff --git a/runner/reporter.go b/runner/reporter.go index 4c4a808e..cdaa76de 100644 --- a/runner/reporter.go +++ b/runner/reporter.go @@ -137,7 +137,7 @@ func (r *Reporter) Run() { var skipCount uint for res := range r.results { - if skipCount < r.config.skipFirst { + if skipCount < uint(r.config.skipFirst) { skipCount++ continue } @@ -185,7 +185,7 @@ func (r *Reporter) Finalize(stopReason StopReason, total time.Duration) *Report Key: r.config.key, CName: r.config.cname, SkipTLS: r.config.skipVerify, - SkipFirst: r.config.skipFirst, + SkipFirst: uint(r.config.skipFirst), Insecure: r.config.insecure, Authority: r.config.authority, Total: uint(r.config.n), diff --git a/www/docs/options.md b/www/docs/options.md index dc371b31..4da83101 100644 --- a/www/docs/options.md +++ b/www/docs/options.md @@ -216,4 +216,8 @@ Show context-sensitive help (also try --help-long and --help-man). ### `-e`, `--enable-compression` -Enable gzip compression on requests. \ No newline at end of file +Enable gzip compression on requests. + +### '--skipFirst' + +Skip the first n responses from the report. Helps remove initial warm-up requests from skewing the results. \ No newline at end of file diff --git a/www/docs/usage.md b/www/docs/usage.md index dc2716f6..a5f6cd35 100644 --- a/www/docs/usage.md +++ b/www/docs/usage.md @@ -43,6 +43,7 @@ Flags: --name= User specified name for the test. --tags= JSON representation of user-defined string tags. --cpus=12 Number of cpu cores to use. + --skipFirst=0 Skip the first n responses from the report. Helps remove initial warm-up requests from skewing the results. --debug= The path to debug log file. -e, --enable-compression Enable Gzip compression on requests. -v, --version Show application version.