mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Added mix_areas_srv and */srv ratio
This commit is contained in:
parent
8d2eecb547
commit
f74660eaeb
1 changed files with 53 additions and 5 deletions
58
test/code.c
58
test/code.c
|
|
@ -85,6 +85,35 @@ static double detect_cpu_clock()
|
||||||
return (tsc_end - tsc_begin) / (tm_end.tv_sec - tm_begin.tv_sec + (tm_end.tv_usec - tm_begin.tv_usec) / 1e6);
|
return (tsc_end - tsc_begin) / (tm_end.tv_sec - tm_begin.tv_sec + (tm_end.tv_usec - tm_begin.tv_usec) / 1e6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mix_areas_srv(unsigned int size,
|
||||||
|
const s16 *src,
|
||||||
|
volatile s32 *sum,
|
||||||
|
unsigned int src_step)
|
||||||
|
{
|
||||||
|
while (size-- > 0) {
|
||||||
|
atomic_add(sum, *src);
|
||||||
|
((char*)src) += src_step;
|
||||||
|
sum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void saturate(unsigned int size,
|
||||||
|
s16 *dst, const s32 *sum,
|
||||||
|
unsigned int dst_step)
|
||||||
|
{
|
||||||
|
while (size-- > 0) {
|
||||||
|
s32 sample = *sum;
|
||||||
|
if (unlikely(sample < -0x8000))
|
||||||
|
*dst = -0x8000;
|
||||||
|
else if (unlikely(sample > 0x7fff))
|
||||||
|
*dst = 0x7fff;
|
||||||
|
else
|
||||||
|
*dst = sample;
|
||||||
|
((char*)dst) += dst_step;
|
||||||
|
sum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mix_areas0(unsigned int size,
|
void mix_areas0(unsigned int size,
|
||||||
volatile s16 *dst, s16 *src,
|
volatile s16 *dst, s16 *src,
|
||||||
volatile s32 *sum,
|
volatile s32 *sum,
|
||||||
|
|
@ -381,7 +410,7 @@ int main(int argc, char **argv)
|
||||||
int size = 2048, n = 4, max = 32267;
|
int size = 2048, n = 4, max = 32267;
|
||||||
int LOOP = 100;
|
int LOOP = 100;
|
||||||
int i, t;
|
int i, t;
|
||||||
unsigned long long begin, end, diff, diff0, diff1, diff1_mmx, diff2;
|
unsigned long long begin, end, diff, diffS, diff0, diff1, diff1_mmx, diff2;
|
||||||
double cpu_clock = detect_cpu_clock();
|
double cpu_clock = detect_cpu_clock();
|
||||||
|
|
||||||
setscheduler();
|
setscheduler();
|
||||||
|
|
@ -407,6 +436,20 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (t = 0, diffS = -1; t < LOOP; t++) {
|
||||||
|
init(dst, sum, size);
|
||||||
|
rdtscll(begin);
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
mix_areas_srv(size, srcs[i], sum, 2);
|
||||||
|
}
|
||||||
|
saturate(size, dst, sum, 2);
|
||||||
|
rdtscll(end);
|
||||||
|
diff = end - begin;
|
||||||
|
if (diff < diffS)
|
||||||
|
diffS = diff;
|
||||||
|
printf("mix_areas_srv : %lld \r", diff); fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
for (t = 0, diff0 = -1; t < LOOP; t++) {
|
for (t = 0, diff0 = -1; t < LOOP; t++) {
|
||||||
init(dst, sum, size);
|
init(dst, sum, size);
|
||||||
rdtscll(begin);
|
rdtscll(begin);
|
||||||
|
|
@ -461,10 +504,15 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
printf(" \r");
|
printf(" \r");
|
||||||
printf("Summary (the best times):\n");
|
printf("Summary (the best times):\n");
|
||||||
printf("mix_areas0 : %lld\n", diff0);
|
printf("mix_areas_srv : %lld %f%%\n", diffS, 100*2*44100.0*diffS/(size*n*cpu_clock));
|
||||||
printf("mix_areas1 : %lld\n", diff1);
|
printf("mix_areas0 : %lld %f%%\n", diff0, 100*2*44100.0*diff0/(size*n*cpu_clock));
|
||||||
printf("mix_areas1_mmx: %lld\n", diff1_mmx);
|
printf("mix_areas1 : %lld %f%%\n", diff1, 100*2*44100.0*diff1/(size*n*cpu_clock));
|
||||||
printf("mix_areas2 : %lld\n", diff2);
|
printf("mix_areas1_mmx: %lld %f%%\n", diff1_mmx, 100*2*44100.0*diff1_mmx/(size*n*cpu_clock));
|
||||||
|
printf("mix_areas2 : %lld %f%%\n", diff2, 100*2*44100.0*diff2/(size*n*cpu_clock));
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
printf("areas1/srv ratio : %f\n", (double)diff1 / diffS);
|
||||||
|
printf("areas1_mmx/srv ratio : %f\n", (double)diff1_mmx / diffS);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue