Skip to content

Commit a773dce

Browse files
authored
Init the seed and add the possibility to specify it (#13)
You can specify it with the -seed param
1 parent e691f21 commit a773dce

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"errors"
55
"flag"
66
"log"
7+
"math/rand"
8+
"time"
79
)
810

911
var (
@@ -16,17 +18,24 @@ var (
1618
fileName string
1719
trafficType string
1820
timeout int
21+
seed int64
1922
ErrInvalidTrafficType = errors.New("Invalid traffic type")
2023
)
2124

2225
func init() {
26+
// Parse the arguments
2327
flag.IntVar(&nbOfClients, "clients", 10, "number of clients making requests")
2428
flag.IntVar(&nbOfRequests, "requests", 10, "number of requests to be made by each clients")
2529
flag.IntVar(&avgMillisecondsToWait, "wait", 1000, "milliseconds to wait between each requests")
2630
flag.IntVar(&timeout, "timeout", 3, "HTTP timeout in seconds")
31+
flag.Int64Var(&seed, "seed", time.Now().UTC().UnixNano(), "seed for the random")
2732
flag.StringVar(&trafficType, "type", "http", "type of requests http/dns")
2833
flag.StringVar(&fileName, "urlSource", "", "optional filepath where to find the URLs")
2934
flag.Parse()
35+
36+
log.SetFlags(0)
37+
log.Println("Random URLs using seed", seed)
38+
rand.Seed(seed)
3039
}
3140

3241
func main() {

0 commit comments

Comments
 (0)