started creating rapid attack command

This commit is contained in:
Senad Uka
2013-11-05 08:17:32 +00:00
parent a354e18116
commit fb197a57d8
4 changed files with 8 additions and 3 deletions

View File

@@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"flag" "flag"
"fmt" "fmt"
vegeta "github.com/tsenart/vegeta/lib" vegeta "github.com/senaduka/vegeta/lib"
"log" "log"
"net/http" "net/http"
"strings" "strings"
@@ -64,7 +64,7 @@ func attack(rate uint64, duration time.Duration, targetsf, ordering, output stri
} }
defer out.Close() defer out.Close()
log.Printf("Vegeta is attacking %d targets in %s order for %s...\n", len(targets), ordering, duration) log.Printf("Vegeta is attacking %d targets in %s order for %s with %d requests/sec...\n", len(targets), ordering, duration, rate)
results := vegeta.Attack(targets, rate, duration) results := vegeta.Attack(targets, rate, duration)
log.Println("Done!") log.Println("Done!")
log.Printf("Writing results to '%s'...", output) log.Printf("Writing results to '%s'...", output)
@@ -74,6 +74,8 @@ func attack(rate uint64, duration time.Duration, targetsf, ordering, output stri
return nil return nil
} }
const ( const (
errRatePrefix = "Rate: " errRatePrefix = "Rate: "
errDurationPrefix = "Duration: " errDurationPrefix = "Duration: "

View File

@@ -16,6 +16,7 @@ type Result struct {
BytesOut uint64 BytesOut uint64
BytesIn uint64 BytesIn uint64
Error string Error string
Rate uint64
} }
// Results is a slice of Result structs with encoding, // Results is a slice of Result structs with encoding,

View File

@@ -18,6 +18,7 @@ var usage = fmt.Sprintf(
Commands: Commands:
attack Hit the targets attack Hit the targets
report Report the results report Report the results
rapid Hit the targets with multiple rates
Globals: Globals:
-cpus=%d Number of CPUs to use -cpus=%d Number of CPUs to use
@@ -34,6 +35,7 @@ func main() {
commands := map[string]func([]string) command{ commands := map[string]func([]string) command{
"attack": attackCmd, "attack": attackCmd,
"report": reportCmd, "report": reportCmd,
"rapid": rapidCmd,
} }
args := flag.Args() args := flag.Args()

View File

@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
for OS in "linux" "darwin"; do for OS in "linux" "darwin"; do
for ARCH in "386" "amd64"; do for ARCH in "amd64"; do
GOOS=$OS CGO_ENABLED=0 GOARCH=$ARCH go build -o vegeta GOOS=$OS CGO_ENABLED=0 GOARCH=$ARCH go build -o vegeta
REV=$(git rev-parse HEAD) REV=$(git rev-parse HEAD)
ARCHIVE=vegeta-$OS-$ARCH-${REV:0:7}.tar.gz ARCHIVE=vegeta-$OS-$ARCH-${REV:0:7}.tar.gz