Guest User

Untitled

a guest
Jun 22nd, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. // gcc -std=gnu99 -Wall -o lvscale lvscale.c -lrt
  2.  
  3. #include <stdio.h>
  4. #include <time.h>
  5.  
  6. #define NPARAM 2000
  7.  
  8. #define RUN 10 // seconds
  9. #define SR 48000 // SPS
  10. #define BS 64 // samples per period
  11.  
  12. static int  __attribute__ ((noinline)) run (float **v) {
  13.     int valid = 0;
  14.     for (int i = 0; i < NPARAM; ++i) {
  15.         if (v[i] != NULL && *(v[i]) >= 0.f && *(v[i]) <= 1.f) {
  16.             ++valid ;
  17.         }
  18.     }
  19.     return valid;
  20. }
  21.  
  22. int main (int argc, char **argv) {
  23.     struct timespec t0, t1;
  24.     float param[NPARAM]; // real param (host)
  25.     float *port[NPARAM]; // mapped param (client)
  26.    
  27.     for (int i = 0; i < NPARAM; ++i) {
  28.         port[i] = & param[i];
  29.     }
  30.  
  31.     clock_gettime (CLOCK_REALTIME, &t0);
  32.     for (int i = 0 ; i < (RUN * SR / BS); ++i) {
  33.         run (port);
  34.     }
  35.     clock_gettime (CLOCK_REALTIME, &t1);
  36.  
  37.     float elapsed = (t1.tv_nsec - t0.tv_nsec) / 1000000.f + (t1.tv_sec - t0.tv_sec) * 1000.f;
  38.     printf ("ELAPSED: %.2f ms  Overhead %.1f%%\n",  elapsed, .1f * elapsed / (float)RUN);
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment