update readme

This commit is contained in:
andy pan 2018-06-28 10:52:20 +08:00
parent e64217c364
commit b62d035ce4
2 changed files with 13 additions and 3 deletions

View File

@ -143,13 +143,17 @@ The test data above is a basic benchmark and the more detailed benchmarks will
![](benchmark_pool.png)
In that benchmark-picture, the first and second benchmarks performed test with 100w tasks and the rest of benchmarks performed test with 1000w tasks, both unlimited goroutines and ants pool, and the capacity of this ants goroutine-pool was limited to 5w.
**As you can see, `ants` can up to 2x faster than goroutines without pool (1000w tasks) and it only consumes half memory comparing with goroutines without pool. (both 100w and 1000w tasks)**
### Benchmarks with PoolWithFunc
![](ants_bench_poolwithfunc.png)
### Throughput
### Throughput ( situation for only submitting tasks and need not waiting for all the tasks to be completed)
#### 10w tasks
@ -165,6 +169,8 @@ The test data above is a basic benchmark and the more detailed benchmarks will
There was only the test of `ants` Pool because my computer was crash when it reached 1000w goroutines.
**As you can see, `ants` can up to 2x~6x faster than goroutines without pool and the memory consumption is reduced by 10 to 20 times.**
[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

View File

@ -147,13 +147,15 @@ Memory : 8 GB 1867 MHz DDR3
![](benchmark_pool.png)
**这里为了模拟大规模goroutine的场景两次测试的并发次数分别是100w和1000w前两个测试分别是执行100w个并发任务不使用Pool和使用了`ants`的Goroutine Pool的性能后两个则是1000w个任务下的表现可以直观的看出在执行速度和内存使用上`ants`的Pool都占有明显的优势。100w的任务量使用`ants`执行速度与原生goroutine相当甚至略快但只实际使用了不到5w个goroutine完成了全部任务且内存消耗仅为原生并发的40%而当任务量达到1000w优势则更加明显了用了70w左右的goroutine完成全部任务执行速度比原生goroutine提高了100%且内存消耗依旧保持在不使用Pool的40%左右。 **
### Benchmarks with PoolWithFunc
![](ants_bench_poolwithfunc.png)
### 吞吐量测试
**因为`PoolWithFunc`这个Pool只绑定一个任务函数也即所有任务都是运行同一个函数所以相较于`Pool`对原生goroutine在执行速度和内存消耗的优势更大上面的结果可以看出执行速度可以达到原生goroutine的300%而内存消耗的优势已经达到了两位数的差距原生goroutine的内存消耗达到了`ants`的35倍且原生goroutine的每次执行的内存分配次数也达到了`ants`45倍1000w的任务量`ants`的初始分配容量是5w因此它完成了所有的任务依旧只使用了5w个goroutine事实上`ants`的Goroutine Pool的容量是可以自定义的也就是说使用者可以根据不同场景对这个参数进行调优直至达到最高性能。 **
### 吞吐量测试(使用于那种只管提交异步任务而无须关心结果的场景)
#### 10w 任务量
@ -169,6 +171,8 @@ Memory : 8 GB 1867 MHz DDR3
1000w任务量的场景下我的电脑已经无法支撑 golang 的原生 goroutine 并发,所以只测出了使用`ants`池的测试结果。
**从该demo测试吞吐性能对比可以看出使用ants的吞吐性能相较于原生goroutine可以保持在2~6倍的性能压制而内存消耗则可以达到10~20倍的节省优势。**
[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