|
4 | 4 | #define S_MP_RAND_JENKINS_C
|
5 | 5 | #include "s_mp_rand_jenkins.c"
|
6 | 6 |
|
| 7 | +/* TODO: Make it an environment variable via main.yml? |
| 8 | + This is for testing only, so no to add checks to the build process. */ |
| 9 | +#include <valgrind/valgrind.h> |
| 10 | + |
7 | 11 | static long rand_long(void)
|
8 | 12 | {
|
9 | 13 | long x;
|
@@ -1163,7 +1167,7 @@ static int test_mp_read_radix(void)
|
1163 | 1167 | char buf[4096];
|
1164 | 1168 | size_t written, maxlen;
|
1165 | 1169 |
|
1166 |
| - int bignum, i, j, k; |
| 1170 | + int bignum, i, j, k, limit_test; |
1167 | 1171 | char *buffer, *bcpy, *startb;
|
1168 | 1172 | clock_t start, stop, t_slow, t_fast;
|
1169 | 1173 | double slow = 0.0, fast = 0.0, sum_slow = 0.0, sum_fast = 0.0;
|
@@ -1195,8 +1199,15 @@ static int test_mp_read_radix(void)
|
1195 | 1199 | printf("%s, %lu\n", buf, (unsigned long)a.dp[0] & 3uL);
|
1196 | 1200 | }
|
1197 | 1201 |
|
| 1202 | + /* Safe a bit of testing time */ |
| 1203 | + if (RUNNING_ON_VALGRIND != 0) { |
| 1204 | + limit_test = 2000; |
| 1205 | + } else { |
| 1206 | + limit_test = 6000; |
| 1207 | + } |
| 1208 | + |
1198 | 1209 | /* Test the fast method with a slightly larger number (about a minute on an older machine) */
|
1199 |
| - for (k = 100; k < 6000; k += 1000) { |
| 1210 | + for (k = 100; k < limit_test; k += 1000) { |
1200 | 1211 | bignum = k;
|
1201 | 1212 | buffer = (char *)malloc((size_t)(bignum + 2));
|
1202 | 1213 | if (buffer == NULL) {
|
@@ -1253,8 +1264,12 @@ static int test_mp_read_radix(void)
|
1253 | 1264 | fprintf(stderr,"Sums for Base %d SLOW: %.10f, FAST: %.10f\n",i, s_bases_slow[i], s_bases_fast[i]);
|
1254 | 1265 | }
|
1255 | 1266 |
|
1256 |
| - /* Very basic check if the fast algorithms are actually faster. */ |
1257 |
| - EXPECT(sum_slow > sum_fast); |
| 1267 | + /* Valgrind overhead does not allow for timings. */ |
| 1268 | + if (RUNNING_ON_VALGRIND == 0) { |
| 1269 | + /* Very basic check if the fast algorithms are actually faster. */ |
| 1270 | + EXPECT(sum_slow > sum_fast); |
| 1271 | + } |
| 1272 | + |
1258 | 1273 |
|
1259 | 1274 | mp_clear_multi(&a, &b, &c, NULL);
|
1260 | 1275 | return EXIT_SUCCESS;
|
|
0 commit comments