Skip to content

Commit

Permalink
Improve method to be more explicit
Browse files Browse the repository at this point in the history
  * The sleep method was hard to disambiguate from library methods.
  * This makes it obvious what is happening.
  • Loading branch information
pdougall1 committed Sep 29, 2015
1 parent 1281eb2 commit 62bb020
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Binary file modified hitit
Binary file not shown.
8 changes: 6 additions & 2 deletions hitit.go
Expand Up @@ -71,8 +71,7 @@ func makeRequest(url string, timeMilliseconds int) <-chan float64 {
out := make(chan float64)
go func() {

r := rand.New(rand.NewSource(time.Now().UnixNano()))
time.Sleep(time.Duration(r.Intn(timeMilliseconds)) * time.Millisecond)
time.Sleep(getTimeDuration(timeMilliseconds) * time.Millisecond)

startTime := time.Now()
_, err := http.Get(url)
Expand All @@ -84,6 +83,11 @@ func makeRequest(url string, timeMilliseconds int) <-chan float64 {
return out
}

func getTimeDuration(timeMilliseconds int) time.Duration {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return time.Duration(r.Intn(timeMilliseconds))
}

func merge(cs []<-chan float64) <-chan float64 {
var wg sync.WaitGroup
out := make(chan float64)
Expand Down

0 comments on commit 62bb020

Please sign in to comment.