Request rate stats and performance tuning

This commit is contained in:
Joona Hoikkala 2018-11-12 20:51:29 +02:00
parent 8b2291dcfe
commit c304f04308
No known key found for this signature in database
GPG key ID: D5AA86BBF9B29A5C
3 changed files with 11 additions and 3 deletions

View file

@ -60,7 +60,7 @@ func main() {
flag.StringVar(&opts.matcherWords, "mw", "", "Match amount of words in response") flag.StringVar(&opts.matcherWords, "mw", "", "Match amount of words in response")
flag.StringVar(&conf.Method, "X", "GET", "HTTP method to use.") flag.StringVar(&conf.Method, "X", "GET", "HTTP method to use.")
flag.BoolVar(&conf.Quiet, "s", false, "Do not print additional information (silent mode)") flag.BoolVar(&conf.Quiet, "s", false, "Do not print additional information (silent mode)")
flag.IntVar(&conf.Threads, "t", 20, "Number of concurrent threads.") flag.IntVar(&conf.Threads, "t", 40, "Number of concurrent threads.")
flag.Parse() flag.Parse()
if err := prepareConfig(&opts, &conf); err != nil { if err := prepareConfig(&opts, &conf); err != nil {
fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err) fmt.Fprintf(os.Stderr, "Encountered error(s): %s\n", err)

View file

@ -75,13 +75,20 @@ func (j *Job) updateProgress() {
// Do not print progress status in silent mode // Do not print progress status in silent mode
return return
} }
runningSecs := int((time.Now().Sub(j.startTime)) / time.Second)
var reqRate int
if runningSecs > 0 {
reqRate = int(j.Counter / runningSecs)
} else {
reqRate = 0
}
dur := time.Now().Sub(j.startTime) dur := time.Now().Sub(j.startTime)
hours := dur / time.Hour hours := dur / time.Hour
dur -= hours * time.Hour dur -= hours * time.Hour
mins := dur / time.Minute mins := dur / time.Minute
dur -= mins * time.Minute dur -= mins * time.Minute
secs := dur / time.Second secs := dur / time.Second
progString := fmt.Sprintf(":: Progress: [%d/%d] :: Duration: [%d:%02d:%02d] ::", j.Counter, j.Total, hours, mins, secs) progString := fmt.Sprintf(":: Progress: [%d/%d] :: %d req/sec :: Duration: [%d:%02d:%02d] ::", j.Counter, j.Total, int(reqRate), hours, mins, secs)
j.Output.Error(progString) j.Output.Error(progString)
} }

View file

@ -27,10 +27,11 @@ func NewSimpleRunner(conf *ffuf.Config) ffuf.RunnerProvider {
simplerunner.config = conf simplerunner.config = conf
simplerunner.client = &http.Client{ simplerunner.client = &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse },
Timeout: time.Duration(10 * time.Second), Timeout: time.Duration(10 * time.Second),
Transport: &http.Transport{ Transport: &http.Transport{
MaxIdleConns: 100,
MaxIdleConnsPerHost: 100,
TLSClientConfig: &tls.Config{ TLSClientConfig: &tls.Config{
InsecureSkipVerify: conf.TLSSkipVerify, InsecureSkipVerify: conf.TLSSkipVerify,
}, },