git/githistory/log: slow it down

This commit is contained in:
Taylor Blau 2017-06-16 11:01:52 -06:00
parent c2242e42d5
commit 5306b6a586

@ -96,16 +96,16 @@ func TestLoggerThrottlesWrites(t *testing.T) {
t1 := make(chan string) t1 := make(chan string)
go func() { go func() {
t1 <- "first" // t = 0 ms, throttle was open t1 <- "first" // t = 0 ms, throttle was open
time.Sleep(3 * time.Millisecond) // t = 3 ms, throttle is closed time.Sleep(10 * time.Millisecond) // t = 10 ms, throttle is closed
t1 <- "second" // t = 3+ε ms, throttle is closed t1 <- "second" // t = 10+ε ms, throttle is closed
time.Sleep(3 * time.Millisecond) // t = 6 ms, throttle is open time.Sleep(10 * time.Millisecond) // t = 20 ms, throttle is open
t1 <- "third" // t = 6+ε ms, throttle was open t1 <- "third" // t = 20+ε ms, throttle was open
close(t1) // t = 6+2ε ms, throttle is closed close(t1) // t = 20+2ε ms, throttle is closed
}() }()
l := NewLogger(&buf) l := NewLogger(&buf)
l.widthFn = func() int { return 0 } l.widthFn = func() int { return 0 }
l.throttle = 5 * time.Millisecond l.throttle = 15 * time.Millisecond
l.enqueue(ChanTask(t1)) l.enqueue(ChanTask(t1))
l.Close() l.Close()
@ -123,14 +123,14 @@ func TestLoggerThrottlesLastWrite(t *testing.T) {
t1 := make(chan string) t1 := make(chan string)
go func() { go func() {
t1 <- "first" // t = 0 ms, throttle was open t1 <- "first" // t = 0 ms, throttle was open
time.Sleep(3 * time.Millisecond) // t = 3 ms, throttle is closed time.Sleep(10 * time.Millisecond) // t = 10 ms, throttle is closed
t1 <- "second" // t = 3+ε ms, throttle is closed t1 <- "second" // t = 10+ε ms, throttle is closed
close(t1) // t = 3+2ε ms, throttle is closed close(t1) // t = 10+2ε ms, throttle is closed
}() }()
l := NewLogger(&buf) l := NewLogger(&buf)
l.widthFn = func() int { return 0 } l.widthFn = func() int { return 0 }
l.throttle = 5 * time.Millisecond l.throttle = 15 * time.Millisecond
l.enqueue(ChanTask(t1)) l.enqueue(ChanTask(t1))
l.Close() l.Close()