-
Notifications
You must be signed in to change notification settings - Fork 0
/
performance.c
87 lines (42 loc) · 1.61 KB
/
performance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/****************************************************************************
Compile with:
gcc example.c -std=c99 -pedantic -W -Wall -Wformat -Wextra -o performance.out
****************************************************************************/
#include "header.h"
int main()
{
printf( "Big Integer Multiplication -- Checks and Performance \n\n");
/***************/
/* Performance */
/***************/
{
printf( "Performance Test....\n" );
long int t1, t2;
t1 = clock();
const bigintexpo k = 16;
const bigintlength l = 1 << k; /* Number of digits */
long int v = 0, vmax = 10;
/* printf( "Multiply %ld-times two numbers of length %ld\n", vmax, l ); */
printf( "-- %ld multiplication of two numbers of %ld digits each in base 2^32\n", vmax, l );
printf( "-- approx. %lld decimal digits\n", (long long) 9 * l );
/*
* We can use several samples:
* Iterate one specific multiplication
* A specific subset of mulitplications
* random numbers
* ...
*/
for( v = 0; v < vmax; v++ ){
bigint P[l], Q[l];
bigint R[2*l];
srand( time(NULL) * rand() + v*v*v*v );
mbiShuffle( l, P, 0 );
mbiShuffle( l, Q, 0 );
mbiMultiply( k, R, P, Q );
}
t2 = clock();
printf( "-- time: %ld0 ms \n", (t2-t1)/10000 );
// printf( "...done.\n" );
}
return 0;
}