简体   繁体   English

iOS GCD 最大并发操作数

[英]iOS GCD Max concurrent operations

On an iPad how many parallel operations can start to get maximum performance?在 iPad 上,有多少并行操作可以开始获得最大性能? in each run a query operation , calculations , etc ...在每次运行查询操作,计算等...

It depends on the iPad model (CPU)?这取决于 iPad 型号(CPU)?

      int count = [objects count];
  if (count > 0)
  {
    dispatch_group_t group = dispatch_group_create();
    dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    for (int i = 0; i < count; i++)
    {
      dispatch_group_async(group, queue, ^{
        for (int j = i + 1; j < count; j++)
        {
          dispatch_group_async(group, queue, ^{
            /** LOTS AND LOTS OF WORK FOR EACH OBJECT **/
          });
        }
      });
    }

        dispatch_group_notify(group, queue, ^{
/** END OF ALL OPERATIONS */
    };


  }

This is basically a UX question.这基本上是一个用户体验问题。 Depends on the needs of the end user.取决于最终用户的需求。
Does he really need all those computations started and finished quickly ?他真的需要快速开始和完成所有这些计算吗?
Can you delay some or most of them ?你能推迟一些或大部分吗?
It's good practice to inform the user with a progress of each computation (a progress bar) and notify him upon completion.通知用户每次计算的进度(进度条)并在完成时通知他是一种很好的做法。
Let him choose which to start / stop / pause (this is a very important feature).让他选择开始/停止/暂停(这是一个非常重要的功能)。

If all the tasks are local - CPU intensive, and not related to network fetching of resources, then it depends on each CPU device - how many threads can it run in parallel.如果所有任务都是本地的——CPU 密集型的,并且与网络获取资源无关,那么它取决于每个 CPU 设备——它可以并行运行多少线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM