mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-12 14:30:54 +08:00
实现基础的206 partial content缓存
This commit is contained in:
41
internal/utils/writers/writer_rate_limit_test.go
Normal file
41
internal/utils/writers/writer_rate_limit_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
||||
|
||||
package writers
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestSleep(t *testing.T) {
|
||||
var count = 2000
|
||||
var wg = sync.WaitGroup{}
|
||||
wg.Add(count)
|
||||
var before = time.Now()
|
||||
for i := 0; i < count; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
time.Sleep(1 * time.Second)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
t.Log(time.Since(before).Seconds()*1000, "ms")
|
||||
}
|
||||
|
||||
func TestTimeout(t *testing.T) {
|
||||
var count = 2000
|
||||
var wg = sync.WaitGroup{}
|
||||
wg.Add(count)
|
||||
var before = time.Now()
|
||||
for i := 0; i < count; i++ {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
var timeout = time.NewTimer(1 * time.Second)
|
||||
<-timeout.C
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
t.Log(time.Since(before).Seconds()*1000, "ms")
|
||||
}
|
||||
Reference in New Issue
Block a user