Giter Club home page Giter Club logo

Comments (7)

CodingHanYa avatar CodingHanYa commented on May 18, 2024

计算的是单个任务的耗时而不是总耗时哦。

from workspace.

SpencerChou avatar SpencerChou commented on May 18, 2024

我的疑问正来于此,任务并没有并行化,所以对于每个线程任务耗时为啥会减少那么多呢? 考虑到任务窃取等也没有道理啊,有的线程执行时间短了,就有的更长,平均下来应该也是200/4=50上下不是嘛

from workspace.

CodingHanYa avatar CodingHanYa commented on May 18, 2024

假设单条线程执行速度不变,但是线程数增多了。那么单位时间内处理的任务增多了,每个任务的平均耗时就降下来了。你把每个任务当成大任务分解出来的小任务,那么实际上就是任务并行化了。

from workspace.

SpencerChou avatar SpencerChou commented on May 18, 2024

我又去看了下代码,然后在看了看benchmark的数据,感觉更懵了
single thread的测试,测出来的是平均下来,那个cpu_bound的函数执行要200多ms,
多线程,那个cpu_bound的函数执行却只要20ms。。。
vecnums和vecsize又没变,问题计算规模又没变小,只是更多个相同的任务在不同的线程上多次计算了,平均耗时怎么会降低呢?

from workspace.

CodingHanYa avatar CodingHanYa commented on May 18, 2024

你再想想

from workspace.

SpencerChou avatar SpencerChou commented on May 18, 2024

大概知道了,还有就是 ,跑空任务的这个意义是在哪呢,这个benchmark能体现线程池的什么能力

from workspace.

CodingHanYa avatar CodingHanYa commented on May 18, 2024

你可以看看我在B站上的讲解视频。跑空任务越快,主要说明主线程同步任务到异步线程的开销越小。

from workspace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.