Files
old-vegeta/main.go

51 lines
1.3 KiB
Go
Raw Normal View History

2013-08-13 13:47:01 +02:00
package main
import (
"flag"
"log"
2013-08-14 18:24:20 +02:00
"runtime"
2013-08-13 13:47:01 +02:00
"time"
)
func main() {
// Global flags
cpus := flag.Int("cpus", runtime.NumCPU(), "Number of CPUs to use")
2013-08-13 13:47:01 +02:00
flag.Parse()
2013-09-08 21:02:04 +01:00
runtime.GOMAXPROCS(*cpus)
args := flag.Args()
if len(args) < 1 {
log.Fatal("Unspecified command")
2013-08-13 13:47:01 +02:00
}
cmd, cmdf := args[0], flag.NewFlagSet(args[0], flag.ExitOnError)
2013-08-16 19:09:06 +02:00
switch cmd {
case "attack":
rate := cmdf.Uint64("rate", 50, "Requests per second")
targetsf := cmdf.String("targets", "targets.txt", "Targets file")
ordering := cmdf.String("ordering", "random", "Attack ordering [sequential, random]")
duration := cmdf.Duration("duration", 10*time.Second, "Duration of the test")
output := cmdf.String("output", "stdout", "Vegeta Results file")
2013-09-07 22:59:12 +01:00
if err := cmdf.Parse(args[1:]); err != nil {
log.Fatal(err)
2013-09-07 22:59:12 +01:00
}
if err := attack(*rate, *duration, *targetsf, *ordering, *output); err != nil {
log.Fatal(err)
}
case "report":
reporter := cmdf.String("reporter", "text", "Reporter [text, json, plot:timings]")
input := cmdf.String("input", "stdin", "Vegeta Results file")
output := cmdf.String("output", "stdout", "Output file")
2013-09-07 22:59:12 +01:00
if err := cmdf.Parse(args[1:]); err != nil {
log.Fatal(err)
}
if err := report(*reporter, *input, *output); err != nil {
log.Fatal(err)
}
2013-08-14 17:48:51 +02:00
default:
log.Fatalf("Unknown command: %s", cmd)
2013-08-13 13:47:01 +02:00
}
}