mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
reduce the goroutine count for unit testing cases of package gfpool/glog
This commit is contained in:
parent
926b664615
commit
23bce7bde6
@ -32,15 +32,15 @@ func Test_ConcurrentOS(t *testing.T) {
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
_, err = f1.Write([]byte("@1234567890#"))
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
_, err = f2.Write([]byte("@1234567890#"))
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 20200)
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2200)
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -54,15 +54,15 @@ func Test_ConcurrentOS(t *testing.T) {
|
||||
t.Assert(err, nil)
|
||||
defer f2.Close()
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
_, err = f1.Write([]byte("@1234567890#"))
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
_, err = f2.Write([]byte("@1234567890#"))
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 20000)
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
path := gfile.Join(gfile.TempDir(), gtime.TimestampNanoStr())
|
||||
@ -76,20 +76,20 @@ func Test_ConcurrentOS(t *testing.T) {
|
||||
defer f2.Close()
|
||||
|
||||
s1 := ""
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
s1 += "@1234567890#"
|
||||
}
|
||||
_, err = f2.Write([]byte(s1))
|
||||
t.Assert(err, nil)
|
||||
|
||||
s2 := ""
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
s2 += "@1234567890#"
|
||||
}
|
||||
_, err = f2.Write([]byte(s2))
|
||||
t.Assert(err, nil)
|
||||
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 20000)
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000)
|
||||
})
|
||||
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
@ -105,7 +105,7 @@ func Test_ConcurrentOS(t *testing.T) {
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
ch := make(chan struct{})
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -114,7 +114,7 @@ func Test_ConcurrentOS(t *testing.T) {
|
||||
t.Assert(err, nil)
|
||||
}()
|
||||
}
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -125,7 +125,7 @@ func Test_ConcurrentOS(t *testing.T) {
|
||||
}
|
||||
close(ch)
|
||||
wg.Wait()
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 20000)
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000)
|
||||
})
|
||||
}
|
||||
|
||||
@ -141,15 +141,15 @@ func Test_ConcurrentGFPool(t *testing.T) {
|
||||
t.Assert(err, nil)
|
||||
defer f2.Close()
|
||||
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
_, err = f1.Write([]byte("@1234567890#"))
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
_, err = f2.Write([]byte("@1234567890#"))
|
||||
t.Assert(err, nil)
|
||||
}
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 20000)
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
path := gfile.Join(gfile.TempDir(), gtime.TimestampNanoStr())
|
||||
@ -164,7 +164,7 @@ func Test_ConcurrentGFPool(t *testing.T) {
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
ch := make(chan struct{})
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -173,7 +173,7 @@ func Test_ConcurrentGFPool(t *testing.T) {
|
||||
t.Assert(err, nil)
|
||||
}()
|
||||
}
|
||||
for i := 0; i < 10000; i++ {
|
||||
for i := 0; i < 1000; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
@ -184,6 +184,6 @@ func Test_ConcurrentGFPool(t *testing.T) {
|
||||
}
|
||||
close(ch)
|
||||
wg.Wait()
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 20000)
|
||||
t.Assert(gstr.Count(gfile.GetContents(path), "@1234567890#"), 2000)
|
||||
})
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
|
||||
func Test_Concurrent(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
c := 10000
|
||||
c := 1000
|
||||
l := glog.New()
|
||||
s := "@1234567890#"
|
||||
f := "test.log"
|
||||
|
Loading…
Reference in New Issue
Block a user