-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
关于加速比 #7
Comments
计算的是单个任务的耗时而不是总耗时哦。 |
我的疑问正来于此,任务并没有并行化,所以对于每个线程任务耗时为啥会减少那么多呢? 考虑到任务窃取等也没有道理啊,有的线程执行时间短了,就有的更长,平均下来应该也是200/4=50上下不是嘛 |
假设单条线程执行速度不变,但是线程数增多了。那么单位时间内处理的任务增多了,每个任务的平均耗时就降下来了。你把每个任务当成大任务分解出来的小任务,那么实际上就是任务并行化了。 |
我又去看了下代码,然后在看了看benchmark的数据,感觉更懵了 |
你再想想 |
大概知道了,还有就是 ,跑空任务的这个意义是在哪呢,这个benchmark能体现线程池的什么能力 |
你可以看看我在B站上的讲解视频。跑空任务越快,主要说明主线程同步任务到异步线程的开销越小。 |
您好,我看到你的benchmark中提到了加速比,我主要是没感觉到这个指标的意义是在哪呢?
单线程4个task,200s
然后线程池4个task50s,这是很正常的。。
但是当任务达到8、16的时候,总耗时为啥会减少呢?我没有想到原因,能否解释一下啊
The text was updated successfully, but these errors were encountered: