Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // gcc -std=gnu99 -Wall -o lvscale lvscale.c -lrt
- #include <stdio.h>
- #include <time.h>
- #define NPARAM 2000
- #define RUN 10 // seconds
- #define SR 48000 // SPS
- #define BS 64 // samples per period
- static int __attribute__ ((noinline)) run (float **v) {
- int valid = 0;
- for (int i = 0; i < NPARAM; ++i) {
- if (v[i] != NULL && *(v[i]) >= 0.f && *(v[i]) <= 1.f) {
- ++valid ;
- }
- }
- return valid;
- }
- int main (int argc, char **argv) {
- struct timespec t0, t1;
- float param[NPARAM]; // real param (host)
- float *port[NPARAM]; // mapped param (client)
- for (int i = 0; i < NPARAM; ++i) {
- port[i] = & param[i];
- }
- clock_gettime (CLOCK_REALTIME, &t0);
- for (int i = 0 ; i < (RUN * SR / BS); ++i) {
- run (port);
- }
- clock_gettime (CLOCK_REALTIME, &t1);
- float elapsed = (t1.tv_nsec - t0.tv_nsec) / 1000000.f + (t1.tv_sec - t0.tv_sec) * 1000.f;
- printf ("ELAPSED: %.2f ms Overhead %.1f%%\n", elapsed, .1f * elapsed / (float)RUN);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment