Phase 29: add project benchmarks, endurance stress and callback safety checks
This commit is contained in:
parent
ca6c869b0b
commit
afc049e2c8
14 changed files with 1032 additions and 43 deletions
|
|
@ -5,8 +5,11 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sys/resource.h>
|
||||
static double now(void)
|
||||
{ struct timespec t; if (clock_gettime(CLOCK_MONOTONIC,&t)) abort(); return (double)t.tv_sec+(double)t.tv_nsec/1e9; }
|
||||
static double cpu_now(void)
|
||||
{ struct timespec t; if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID,&t)) abort(); return (double)t.tv_sec+(double)t.tv_nsec/1e9; }
|
||||
static int compare(const void *a,const void *b)
|
||||
{ double x = *(const double *)a,y = *(const double *)b; return x < y ? -1 : x > y; }
|
||||
static size_t number(const char *s,size_t maximum)
|
||||
|
|
@ -21,7 +24,9 @@ int main(int argc,char **argv)
|
|||
size_t nodes,channels,rate,frames,blocks,i,j,id = 0,previous = 0;
|
||||
xtc_graph *g = NULL; xtc_plan *p = NULL;
|
||||
float *in = NULL,*left = NULL,*right = NULL;
|
||||
double *times = NULL,begin,compile,total = 0;
|
||||
double *times = NULL,begin,compile,total = 0,cpu_begin,cpu;
|
||||
size_t misses = 0;
|
||||
struct rusage usage;
|
||||
int status = 1;
|
||||
if (argc != 6) return 1;
|
||||
nodes = number(argv[1],256); channels = number(argv[2],2); rate = number(argv[3],768000);
|
||||
|
|
@ -42,18 +47,22 @@ int main(int argc,char **argv)
|
|||
for (i = 0; i < frames; ++i) in[i] = (float)sin((double)i*.1)*.1f;
|
||||
/* Warm caches outside the sample, then measure only the process call. */
|
||||
for (i = 0; i < 20; ++i) if (xtc_plan_process_stereo(p,in,NULL,NULL,NULL,NULL,left,channels == 2 ? right : NULL,frames) != XTC_OK) goto done;
|
||||
cpu_begin = cpu_now();
|
||||
for (i = 0; i < blocks; ++i) {
|
||||
begin = now();
|
||||
if (xtc_plan_process_stereo(p,in,NULL,NULL,NULL,NULL,left,channels == 2 ? right : NULL,frames) != XTC_OK) goto done;
|
||||
times[i] = now()-begin; total += times[i];
|
||||
if (times[i] > (double)frames/(double)rate) ++misses;
|
||||
for (j = 0; j < frames; ++j) if (!isfinite(left[j]) || (channels == 2 && !isfinite(right[j]))) goto done;
|
||||
}
|
||||
cpu = cpu_now()-cpu_begin;
|
||||
if (getrusage(RUSAGE_SELF,&usage)) goto done;
|
||||
qsort(times,blocks,sizeof(double),compare);
|
||||
printf("{\"nodes\":%zu,\"channels\":%zu,\"rate\":%zu,\"frames\":%zu,\"blocks\":%zu,"
|
||||
"\"compile_ms\":%.6f,\"mean_us\":%.6f,\"p99_us\":%.6f,\"max_us\":%.6f,\"deadline_us\":%.6f,"
|
||||
"\"load\":%.6f,\"graph_buffer_bytes\":%zu}\n",nodes,channels,rate,frames,blocks,compile*1e3,total/(double)blocks*1e6,
|
||||
"\"load\":%.6f,\"graph_buffer_bytes\":%zu,\"deadline_misses\":%zu,\"process_cpu_ms\":%.6f,\"peak_rss_kib\":%ld}\n",nodes,channels,rate,frames,blocks,compile*1e3,total/(double)blocks*1e6,
|
||||
times[blocks*99/100]*1e6,times[blocks-1]*1e6,(double)frames/(double)rate*1e6,
|
||||
total/(double)blocks/((double)frames/(double)rate),nodes*frames*2*sizeof(float));
|
||||
total/(double)blocks/((double)frames/(double)rate),nodes*frames*2*sizeof(float),misses,cpu*1e3,usage.ru_maxrss);
|
||||
status = 0;
|
||||
done:
|
||||
free(in); free(left); free(right); free(times); xtc_plan_destroy(p); xtc_graph_destroy(g); return status;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue