void dspstress_perform64(t_dspstress *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam) { float spintime; double intime; double outtime; unsigned long spincounter = 0; spintime = x->x_svtime_ms * x->x_cpuusagetarget / 100.; intime = systimer_gettime(); outtime = intime + spintime; while (systimer_gettime() < outtime) { // tra la la spincounter++; // how high can we count? } }
void threadpool_dotask(t_threadpool *x, t_symbol *s, long ac, t_atom *av) { long i; double f=0.74; double start = systimer_gettime(); double end; long textsize=0; char *tmpstr=NULL; atom_gettext(ac,av,&textsize,&tmpstr,0); post("threadpool starting background task (%s)",tmpstr); for (i=0;i<100000000;i++) { f = sqrt(sin(f)*sin(f) + cos(f)*cos(f)); } end = systimer_gettime(); post("threadpool finished background task (%s) result=%f time=%f",tmpstr,f,end-start); if (tmpstr) sysmem_freeptr(tmpstr); }
void *simpleparallel_threadproc(t_sysparallel_worker *w) { t_simpleparallel *x = (t_simpleparallel *)w->data; int i,myfoo=0,iterations; double time = systimer_gettime(); object_post((t_object *)x,"worker %ld of %ld started",w->id,w->task->workercount); // do some work iterations = x->x_iterations; for (i=0; i<iterations; i++) { myfoo++; } // increment our main value systhread_mutex_lock(x->x_mutex); x->x_foo += myfoo; // fiddle with shared data systhread_mutex_unlock(x->x_mutex); object_post((t_object *)x,"worker %ld of %ld ended (%fms)",w->id,w->task->workercount,systimer_gettime()-time); return NULL; }