Advertisement
Guest User

Untitled

a guest
Dec 15th, 2014
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. static void sampling(FILE *logf, float out[32], const int n)
  2. {
  3.     const int TRANS_NUM = N_MAX / BLOCK_NUM;
  4.     assert(n <= TRANS_NUM);
  5.  
  6.     const uint8_t *pool = &g_commandpool[0];
  7.     const uint32_t commandlen = g_commandlen;
  8.  
  9.     const bool tbc = g_use_time_base_correction;
  10.     const int basemasure_n = 10; // 増やし過ぎないほうが良さそう
  11.     double base = 0;
  12.     double newbase = 0;
  13.  
  14.     if (tbc)
  15.         base = measure(pool, basemasure_n);
  16.  
  17.     for (int i = 0; i < 32; i++) {
  18.         const int ix = order_R(i);
  19.  
  20.         const uint32_t R = 1 << ix;
  21.         const uint8_t *command = pool + commandlen * TRANS_NUM * ix;
  22.  
  23.         static const char *ordinal[] = { "", "1st", "2nd", "3rd", "4th" };
  24.         teeprintf(logf, "%s R: %08x / total_ave : ", ordinal[g_stage], R);
  25.  
  26.         double total_ave = measure(command, n) / n;
  27.  
  28.         if (tbc) {
  29.             newbase = measure(pool, basemasure_n);
  30.             const double t = base / ((base + newbase) * 0.5);
  31.             total_ave *= t;
  32.             teeprintf(logf, "%f ms / x%f, %+f ms\n", total_ave, t, newbase - base);
  33.         }
  34.         else {
  35.             teeprintf(logf, "%f ms\n", total_ave);
  36.         }
  37.  
  38.         out[ix] = static_cast<float>(total_ave);
  39.  
  40.         base = newbase;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement