Skip to content

Commit 19d6a93

Browse files
committed
excluded timing from valgrind run
1 parent 131177c commit 19d6a93

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

demo/test.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
#define S_MP_RAND_JENKINS_C
55
#include "s_mp_rand_jenkins.c"
66

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+
711
static long rand_long(void)
812
{
913
long x;
@@ -1163,7 +1167,7 @@ static int test_mp_read_radix(void)
11631167
char buf[4096];
11641168
size_t written, maxlen;
11651169

1166-
int bignum, i, j, k;
1170+
int bignum, i, j, k, limit_test;
11671171
char *buffer, *bcpy, *startb;
11681172
clock_t start, stop, t_slow, t_fast;
11691173
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)
11951199
printf("%s, %lu\n", buf, (unsigned long)a.dp[0] & 3uL);
11961200
}
11971201

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+
11981209
/* 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) {
12001211
bignum = k;
12011212
buffer = (char *)malloc((size_t)(bignum + 2));
12021213
if (buffer == NULL) {
@@ -1253,8 +1264,12 @@ static int test_mp_read_radix(void)
12531264
fprintf(stderr,"Sums for Base %d SLOW: %.10f, FAST: %.10f\n",i, s_bases_slow[i], s_bases_fast[i]);
12541265
}
12551266

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+
12581273

12591274
mp_clear_multi(&a, &b, &c, NULL);
12601275
return EXIT_SUCCESS;

tommath_class.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,11 +1109,10 @@
11091109
# define MP_INIT_C
11101110
# define MP_INIT_I32_C
11111111
# define MP_INIT_MULTI_C
1112-
# define MP_MUL_2D_C
1113-
# define MP_MUL_2_C
11141112
# define MP_MUL_C
11151113
# define MP_SUB_C
11161114
# define MP_SUB_D_C
1115+
# define S_MP_COMPUTE_S_C
11171116
# define S_MP_SLOWER_TO_RADIX_C
11181117
# define S_MP_TO_RADIX_RECURSIVE_C
11191118
# define S_MP_ZERO_BUF_C

0 commit comments

Comments
 (0)