title: Should we use cuda Event to time thrust function (such as sort) or should we use cpu timers
body: <p>I am trying to time the thrust sort function . Present, i am using cuda events. but i was curious if cuda events will give me the wrong value.  This is because, on my computer, thrust is sorting 2 million floats in GPU in 34 ms. But this seems too fast</p>
  
  <p>I tried both CPU and GPU times and got following:</p>
  
  <p>CPU ( takes around 36 ms)</p>
  
  <pre><code>__int64 ctr1 = 0 , ctr2 = 0 , freq = 0 ;
      QueryPerformanceFrequency((LARGE_INTEGER *) &amp;freq);
      QueryPerformanceCounter((LARGE_INTEGER *) &amp;ctr1);
      thrust::sort(D.begin(),D.end());
      // transfer data back to host   
      thrust::copy(D.begin(), D.end(), H.begin());
      cudaThreadSynchronize(); // block until kernel is finished
  
     QueryPerformanceCounter((LARGE_INTEGER *)&amp;ctr2);
      double ans = ((ctr2 - ctr1) * 1.0 / freq);
      printf("The time elapsed in milliseconds is %f\n",(ans*1000));
  </code></pre>
  
  <p>GPU</p>
  
  <pre><code>cudaEvent_t start, stop;
  cudaEventCreate(&amp;start);
  cudaEventCreate(&amp;stop);
  cudaEventRecord(start, 0);
  thrust::sort(D.begin(),D.end());
  
  thrust::copy(D.begin(), D.end(), H.begin());
  cudaEventRecord(stop, 0);
  cudaEventSynchronize(stop);
  float elapsedTime; 
  cudaEventElapsedTime(&amp;elapsedTime , start, stop);
  printf("time is %f ms", elapsedTime);
  </code></pre>
  
  <p>Please let me know which timing is correct</p>
  
  <p>Thanks</p>