Comments (7)
计算的是单个任务的耗时而不是总耗时哦。
from workspace.
我的疑问正来于此,任务并没有并行化,所以对于每个线程任务耗时为啥会减少那么多呢? 考虑到任务窃取等也没有道理啊,有的线程执行时间短了,就有的更长,平均下来应该也是200/4=50上下不是嘛
from workspace.
假设单条线程执行速度不变,但是线程数增多了。那么单位时间内处理的任务增多了,每个任务的平均耗时就降下来了。你把每个任务当成大任务分解出来的小任务,那么实际上就是任务并行化了。
from workspace.
我又去看了下代码,然后在看了看benchmark的数据,感觉更懵了
single thread的测试,测出来的是平均下来,那个cpu_bound的函数执行要200多ms,
多线程,那个cpu_bound的函数执行却只要20ms。。。
vecnums和vecsize又没变,问题计算规模又没变小,只是更多个相同的任务在不同的线程上多次计算了,平均耗时怎么会降低呢?
from workspace.
你再想想
from workspace.
大概知道了,还有就是 ,跑空任务的这个意义是在哪呢,这个benchmark能体现线程池的什么能力
from workspace.
你可以看看我在B站上的讲解视频。跑空任务越快,主要说明主线程同步任务到异步线程的开销越小。
from workspace.
Related Issues (20)
- 稳定性测试脚本的问题 HOT 1
- ubuntu 20下,起进程,这个进程无法关闭 HOT 1
- 请问线程池可以处理高递归的任务吗 HOT 1
- 关于任务窃取机制的疑问 HOT 3
- 关于submitForReturn函数是否能执行带参数的函数的问题 HOT 3
- 卧槽,名字都改掉了 HOT 1
- 建议启用以下cmake功能 HOT 1
- 在Issues中看到了有对应的b站视频,up主能否挂一下链接 HOT 1
- 请教关于workspace HOT 3
- CMakeLists.txt有点问题 HOT 6
- 知乎上看到说这个库还有对应的解析视频?不知道哪里可以看到? HOT 1
- 重构问题 HOT 2
- workbranch::mission里访问workbranch::decline不用加锁吗? HOT 1
- 请求一些意见
- 线程返回超时问题 HOT 2
- 关于win 中引用当前workspace库 使用c++14报错的问题 HOT 4
- 如何取消指定任务? HOT 1
- 空载时CPU占用巨高 HOT 1
- Futures类成员函数返回临时变量的引用 HOT 1
- 动态线程调整相关 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from workspace.