title: How to measure the execution speed of launch::async?
body: <p>I'm working on my assignment and trying to measure the execution speed on the <code>async</code> policy.
  The time I get without iterating the <code>raNums</code> vector is about 60 seconds, which is quite a lot. And with its iteration - 9 milliseconds, which is quite a bit (I understand that in this case, processes are going without stop). However, I don't really understand how I suppose to catch the right time of execution async?</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;future&gt;
  #include &lt;random&gt;
  
  using namespace std;
  using namespace std::chrono;
  
  class RandomNum {
  public:
      enum class Task {
          SMALL,
          BIG
      };
      Task task;
  
      RandomNum() {
          pickNum();
      }
  
      int randNum() {
          if (task == RandomNum::Task::SMALL) {
              for (int i = 0; i &lt; 100; i++) {
                  rand();
              }
          }
          else if (task == RandomNum::Task::BIG) {
              for (int i = 0; i &lt; 10000000; i++) {
                  rand();
              }
          }
          return 0;
      }
  
  private:
  
      void pickNum() {
          int randNum = rand() % 100 + 1;
          task = (randNum % 2 == 0) ? RandomNum::Task::SMALL : RandomNum::Task::BIG;
      }
  
  };
  
  int main()
  {
      srand((unsigned int)time(NULL));
  
      vector&lt;RandomNum*&gt; raNums;
  
      for (auto i = 0; i &lt; 100; i++) {
          raNums.push_back(new RandomNum());
      }
  
      auto start = steady_clock::now();
  
      vector&lt;future&lt;int&gt;&gt; res;
  
      for (auto&amp; value : raNums) {
          //if (value-&gt;task == RandomNum::Task::SMALL) {
          //  res.push_back(async(launch::deferred, &amp;RandomNum::randNum, value));
          //}
          //else {
          //  res.push_back(async(launch::async, &amp;RandomNum::randNum, value));
          //}
          res.push_back(async(launch::async, &amp;RandomNum::randNum, value));
      }
  
  
      for (auto&amp; i : res) {
          i.get();
      }
  
      auto stop = steady_clock::now();
  
      cout &lt;&lt; &quot;Time = &quot; &lt;&lt; duration_cast&lt;milliseconds&gt;(stop - start).count() &lt;&lt; &quot;ms.\n&quot;;
  
      return 0;
  }
  </code></pre>