1 module botan_math.test;
2 
3 import botan_math.mp_types;
4 import botan_math.mp_comba;
5 import std.datetime;
6 import std.conv;
7 import std.stdio : writeln;
8 unittest {
9 	void testCombaSqr4() {
10 		word[8] z;
11 		word[4] x = [word.max, word.max, word.max, word.max];
12 		
13 		StopWatch sw; sw.start();
14 		foreach (i; 0 .. 1000000) {
15 			bigint_comba_sqr4(z, x);
16 		}
17 		sw.stop();
18 		writeln("bigint_comba_sqr4: ", sw.peek().msecs);		
19 	}
20 	void testCombaMul4() {
21 		word[4] x = [word.max, word.max, word.max, word.max];
22 		word[4] y = [word.max, word.max, word.max, word.max];
23 		word[8] z;word[10000] w1;
24 		StopWatch sw; word[1000] w;sw.start();
25 		foreach (i; 0 .. 1000000) {
26 			bigint_comba_mul4(z, x, y);
27 		}
28 		sw.stop();
29 		writeln("bigint_comba_mul4: ", sw.peek().msecs);	
30 		
31 	}
32 	void testCombaSqr6() {
33 		word[6] x = [word.max, word.max, word.max, word.max, word.max, word.max];
34 		word[12] z;
35 		StopWatch sw; sw.start();
36 		foreach (i; 0 .. 1000000) {
37 			bigint_comba_sqr6(z, x);
38 		}
39 		sw.stop();
40 		writeln("bigint_comba_sqr6: ", sw.peek().msecs);		
41 	}
42 
43 	void testCombaMul6() {
44 		word[6] x = [word.max, word.max, word.max, word.max, word.max, word.max];
45 		word[6] y = [word.max, word.max, word.max, word.max, word.max, word.max];
46 		word[12] z;
47 		StopWatch sw; sw.start();
48 		foreach (i; 0 .. 1000000) {
49 			bigint_comba_mul6(z, x, y);
50 		}
51 		sw.stop();
52 		writeln("bigint_comba_mul6: ", sw.peek().msecs);		
53 	}
54 	void testCombaSqr8() {
55 		word[8] x = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
56 		word[16] z;
57 		StopWatch sw; sw.start();
58 		foreach (i; 0 .. 1000000) {
59 			bigint_comba_sqr8(z, x);
60 		}
61 		sw.stop();
62 		writeln("bigint_comba_sqr8: ", sw.peek().msecs);		
63 	}
64 
65 	void testCombaMul8() {
66 		word[8] x = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
67 		word[8] y = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
68 		word[16] z;
69 		StopWatch sw; sw.start();
70 		foreach (i; 0 .. 1000000) {
71 			bigint_comba_mul8(z, x, y);
72 		}
73 		sw.stop();
74 		writeln("bigint_comba_mul8: ", sw.peek().msecs);		
75 	}
76 
77 	void testCombaSqr9() {
78 		word[9] x = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
79 		word[18] z;
80 		StopWatch sw; sw.start();
81 		foreach (i; 0 .. 1000000) {
82 			bigint_comba_sqr9(z, x);
83 		}
84 		sw.stop();
85 		writeln("bigint_comba_sqr9: ", sw.peek().msecs);		
86 	}
87 	
88 	void testCombaMul9() {
89 		word[9] x = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
90 		word[9] y = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
91 		word[18] z;
92 		StopWatch sw; sw.start();
93 		foreach (i; 0 .. 1000000) {
94 			bigint_comba_mul9(z, x, y);
95 		}
96 		sw.stop();
97 		writeln("bigint_comba_mul9: ", sw.peek().msecs);		
98 	}
99 
100 	void testCombaSqr16() {
101 		word[16] x = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max,
102 			word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
103 		word[32] z;
104 		StopWatch sw; sw.start();
105 		foreach (i; 0 .. 1000000) {
106 			bigint_comba_sqr16(z, x);
107 		}
108 		sw.stop();
109 		writeln("bigint_comba_sqr16: ", sw.peek().msecs);		
110 	}
111 
112 	void testCombaMul16() {
113 		word[16] x = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max,
114 			word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
115 		word[16] y = [word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max,
116 			word.max, word.max, word.max, word.max, word.max, word.max, word.max, word.max];
117 		word[32] z;
118 		StopWatch sw; sw.start();
119 		foreach (i; 0 .. 1000000) {
120 			bigint_comba_mul16(z, x, y);
121 		}
122 		sw.stop();
123 		writeln("bigint_comba_mul16: ", sw.peek().msecs);		
124 	}
125 
126 	testCombaSqr4();
127 	testCombaMul4();
128 	testCombaSqr6();
129 	testCombaMul6();
130 	testCombaSqr8();
131 	testCombaMul8();
132 	testCombaSqr9();
133 	testCombaMul9();
134 	testCombaSqr16();
135 	testCombaMul16();
136 
137 }