Mercurial > vec
comparison test/test_benchmark.h @ 39:f9ca85d2f14c
*: rearrange some things; add avx512bw support
author | Paper <paper@tflc.us> |
---|---|
date | Sat, 26 Apr 2025 15:31:39 -0400 |
parents | 4b5a557aa64f |
children | c6e0df09b86f |
comparison
equal
deleted
inserted
replaced
38:fd42f9b1b95e | 39:f9ca85d2f14c |
---|---|
1 | 1 |
2 /* ------------------------------------------------------------------------ */ | 2 /* ------------------------------------------------------------------------ */ |
3 /* simple benchmark for getting the min/max range of an audio sample. */ | 3 /* simple benchmark for getting the min/max range of an audio sample. */ |
4 | |
5 /* prevent GCC from optimizing these function calls away - i think there's | |
6 * probably a better way to do this, but I haven't found it yet :) */ | |
7 | |
8 | 4 |
9 extern void test_benchmark_sample_minmax_simple_impl(int16_t *smpl, uint32_t length, int32_t *pmin, int32_t *pmax); | 5 extern void test_benchmark_sample_minmax_simple_impl(int16_t *smpl, uint32_t length, int32_t *pmin, int32_t *pmax); |
10 extern void test_benchmark_sample_minmax_vec_impl(int16_t *smpl, uint32_t length, int32_t *pmin, int32_t *pmax); | 6 extern void test_benchmark_sample_minmax_vec_impl(int16_t *smpl, uint32_t length, int32_t *pmin, int32_t *pmax); |
11 | 7 |
12 VEC_FUNC_IMPL void test_benchmark_sample_minmax(void) | 8 VEC_FUNC_IMPL void test_benchmark_sample_minmax(void) |
13 { | 9 { |
14 int32_t min, max; | 10 int32_t min, max; |
15 clock_t start, end; | 11 clock_t start, end; |
16 int i; | 12 int i; |
17 int16_t *q = vec_malloc(16000000u * 2u); | 13 int16_t *q = vec_malloc(16000001u * 2u); |
18 | 14 |
19 printf("\nsigned 16-bit audio sample min/max - 1 thousand passes - 16000000 samples\n\n"); | 15 printf("\nsigned 16-bit audio sample min/max - 1 thousand passes - 16000001 samples\n\n"); |
20 | 16 |
21 /* generate random sample values */ | 17 /* generate random sample values */ |
22 for (i = 0; i < 16000000; i++) | 18 for (i = 0; i < 16000001; i++) |
23 q[i] = rand(); | 19 q[i] = rand(); |
24 | 20 |
25 start = clock(); | 21 start = clock(); |
26 for (i = 0; i < 1000; i++) { | 22 for (i = 0; i < 1000; i++) { |
27 min = INT32_MAX; | 23 min = INT32_MAX; |
28 max = INT32_MIN; | 24 max = INT32_MIN; |
29 test_benchmark_sample_minmax_vec_impl(q, 16000000u, &min, &max); | 25 test_benchmark_sample_minmax_vec_impl(q, 16000001u, &min, &max); |
30 } | 26 } |
31 end = clock(); | 27 end = clock(); |
32 | 28 |
33 printf("- vec: took %f secs\n", (double)(end - start) / CLOCKS_PER_SEC); | 29 printf("- vec: took %f secs\n", (double)(end - start) / CLOCKS_PER_SEC); |
34 | 30 |
35 start = clock(); | 31 start = clock(); |
36 for (i = 0; i < 1000; i++) { | 32 for (i = 0; i < 1000; i++) { |
37 min = INT32_MAX; | 33 min = INT32_MAX; |
38 max = INT32_MIN; | 34 max = INT32_MIN; |
39 test_benchmark_sample_minmax_simple_impl(q, 16000000u, &min, &max); | 35 test_benchmark_sample_minmax_simple_impl(q, 16000001u, &min, &max); |
40 } | 36 } |
41 end = clock(); | 37 end = clock(); |
42 | 38 |
43 printf("- simple: took %f secs\n", (double)(end - start) / CLOCKS_PER_SEC); | 39 printf("- simple: took %f secs\n", (double)(end - start) / CLOCKS_PER_SEC); |
44 | 40 |