|
|
@ -10,7 +10,9 @@ import (
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var chunk_size = 100
|
|
|
|
var chunk_size = 1
|
|
|
|
|
|
|
|
var chunk_target = 250 * time.Millisecond
|
|
|
|
|
|
|
|
var chunk_max = 10000
|
|
|
|
|
|
|
|
|
|
|
|
var options struct {
|
|
|
|
var options struct {
|
|
|
|
host string
|
|
|
|
host string
|
|
|
@ -34,10 +36,10 @@ type chunk struct {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *chunk) send(w *bufio.Writer, responses chan maybe) {
|
|
|
|
func (c *chunk) send(w *bufio.Writer, responses chan maybe) {
|
|
|
|
|
|
|
|
start := time.Now()
|
|
|
|
for _, v := range c.vals {
|
|
|
|
for _, v := range c.vals {
|
|
|
|
v.Write(w)
|
|
|
|
v.Write(w)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
start := time.Now()
|
|
|
|
|
|
|
|
size := w.Buffered()
|
|
|
|
size := w.Buffered()
|
|
|
|
w.Flush()
|
|
|
|
w.Flush()
|
|
|
|
errors, replies := 0, 0
|
|
|
|
errors, replies := 0, 0
|
|
|
@ -69,10 +71,19 @@ func (c *chunk) send(w *bufio.Writer, responses chan maybe) {
|
|
|
|
elapsed := time.Since(start)
|
|
|
|
elapsed := time.Since(start)
|
|
|
|
sleep := elapsed / 4
|
|
|
|
sleep := elapsed / 4
|
|
|
|
time.Sleep(sleep)
|
|
|
|
time.Sleep(sleep)
|
|
|
|
if true {
|
|
|
|
|
|
|
|
avg := time.Duration(int64(elapsed) / int64(len(c.vals)))
|
|
|
|
avg := time.Duration(int64(elapsed) / int64(len(c.vals)))
|
|
|
|
fmt.Printf("id: %d errors: %d replies: %d total: %d sent: %d elapsed: %v avg: %v size: %v sleep: %v\n",
|
|
|
|
next_size := int(int64(chunk_target) / int64(avg))
|
|
|
|
c.id, errors, replies, errors+replies, len(c.vals), elapsed, avg, size, sleep)
|
|
|
|
if true {
|
|
|
|
|
|
|
|
fmt.Printf("id: %d errors: %d replies: %d total: %d sent: %d elapsed: %v avg: %v size: %v sleep: %v next_size: %v\n",
|
|
|
|
|
|
|
|
c.id, errors, replies, errors+replies, len(c.vals), elapsed, avg, size, sleep, next_size)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if next_size < chunk_size*2 {
|
|
|
|
|
|
|
|
chunk_size = next_size
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
chunk_size *= 2
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if chunk_size > chunk_max {
|
|
|
|
|
|
|
|
chunk_size = chunk_max
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|