forked from mirror/ants
Merge branch 'develop'
This commit is contained in:
commit
3dff642352
26
README.md
26
README.md
|
@ -137,6 +137,32 @@ All the tasks submitted to ants pool will not be guaranteed to be processed in o
|
|||
|
||||
The test data above is a basic benchmark and the more detailed benchmarks will be uploaded later.
|
||||
|
||||
### Benchmarks with Pool
|
||||
|
||||
![](https://github.com/panjf2000/ants/blob/master/benchmark_pool.png)
|
||||
|
||||
|
||||
|
||||
### Benchmarks with PoolWithFunc
|
||||
|
||||
![](https://github.com/panjf2000/ants/blob/master/ants_bench_poolwithfunc.png)
|
||||
|
||||
### Throughput
|
||||
|
||||
#### 10w tasks
|
||||
|
||||
![](https://github.com/panjf2000/ants/blob/master/ants_bench_10w.png)
|
||||
|
||||
#### 100w tasks
|
||||
|
||||
![](https://github.com/panjf2000/ants/blob/master/ants_bench_100w.png)
|
||||
|
||||
#### 1000W tasks
|
||||
|
||||
![](https://github.com/panjf2000/ants/blob/master/ants_bench_1000w.png)
|
||||
|
||||
There was only the test of `ants` Pool because my computer was crash when it reached 1000w goroutines. ba
|
||||
|
||||
[1]: https://godoc.org/github.com/panjf2000/ants?status.svg
|
||||
[2]: https://godoc.org/github.com/panjf2000/ants
|
||||
[3]: https://goreportcard.com/badge/github.com/panjf2000/ants
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 84 KiB |
Binary file not shown.
After Width: | Height: | Size: 138 KiB |
Binary file not shown.
After Width: | Height: | Size: 202 KiB |
Binary file not shown.
After Width: | Height: | Size: 176 KiB |
|
@ -45,7 +45,8 @@ const RunTimes = 10000000
|
|||
const loop = 10
|
||||
|
||||
func demoFunc() error {
|
||||
time.Sleep(loop * time.Millisecond)
|
||||
n := 10
|
||||
time.Sleep(time.Duration(n) * time.Millisecond)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -95,17 +96,18 @@ func BenchmarkAntsPoolWithFunc(b *testing.B) {
|
|||
func BenchmarkGoroutine(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
for j := 0; j < RunTimes; j++ {
|
||||
go demoFunc()
|
||||
go demoPoolFunc(loop)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func BenchmarkAntsPool(b *testing.B) {
|
||||
p, _ := ants.NewPoolWithFunc(50000, demoPoolFunc)
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for j := 0; j < RunTimes; j++ {
|
||||
ants.Submit(demoFunc)
|
||||
p.Serve(loop)
|
||||
}
|
||||
b.Logf("running goroutines: %d", ants.Running())
|
||||
// b.Logf("running goroutines: %d", p.Running())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import (
|
|||
"github.com/panjf2000/ants"
|
||||
)
|
||||
|
||||
var n = 10000000
|
||||
var n = 1000000
|
||||
|
||||
func TestDefaultPool(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 255 KiB |
Loading…
Reference in New Issue