8 #include <sys/resource.h>
16 return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000;
21 #ifndef CLOCKS_PER_SEC
22 #define CLOCKS_PER_SEC 1000000
25 #if CLOCKS_PER_SEC >= 10000
26 #define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000))
28 #define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC)
34 return CLOCK_TO_MILLISEC (clock ());
41 #if defined (__m88k__)
43 #elif defined (__i386__)
44 #define CLOCK (16.666667 M)
45 #elif defined (__m68k__)
47 #elif defined (_IBMR2)
49 #elif defined (__sparc__)
51 #elif defined (__sun__)
53 #elif defined (__mips)
55 #elif defined (__hppa__)
57 #elif defined (__alpha)
60 #error "Don't know CLOCK of your machine"
71 #define TIMES OPS/SIZE
74 #define OPS (SIZE*TIMES)
78 refmpn_lshift (wp, up, usize, cnt)
80 register mp_srcptr up;
82 register unsigned int cnt;
84 register mp_limb_t high_limb, low_limb;
85 register unsigned sh_1, sh_2;
90 if (usize == 0 || cnt == 0)
100 /* Copy from high end to low end, to allow specified input/output
102 for (i = usize - 1; i >= 0; i--)
110 sh_2 = BITS_PER_MP_LIMB - sh_1;
113 retval = low_limb >> sh_2;
114 high_limb = low_limb;
118 wp[i] = (high_limb << sh_1) | (low_limb >> sh_2);
119 high_limb = low_limb;
121 wp[i] = high_limb << sh_1;
135 mp_limb_t dx[SIZE+2];
136 mp_limb_t dy[SIZE+2];
144 for (test = 0; ; test++)
147 size = (random () % SIZE + 1);
151 mpn_random2 (s1, size);
153 dx[size+1] = 0x12345678;
154 dy[size+1] = 0x12345678;
159 mpn_print (s1, size);
162 for (i = 0; i < TIMES; i++)
163 cyx = refmpn_lshift (dx+1, s1, size, cnt);
166 printf ("refmpn_lshift: %5ldms (%.2f cycles/limb)\n",
168 ((double) t * CLOCK) / (OPS * 1000.0));
171 printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); mpn_print (dx+1, size);
175 for (i = 0; i < TIMES; i++)
176 cyy = mpn_lshift (dx+1, s1, size, cnt);
179 printf ("mpn_lshift: %5ldms (%.2f cycles/limb)\n",
181 ((double) t * CLOCK) / (OPS * 1000.0));
184 printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); mpn_print (dx+1, size);
188 /* Put garbage in the destination. */
189 for (i = 1; i <= size; i++)
195 cyx = refmpn_lshift (dx+1, s1, size, cnt);
196 cyy = mpn_lshift (dy+1, s1, size, cnt);
198 if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0
199 || dx[size+1] != 0x12345678 || dx[0] != 0x87654321)
202 printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx);
203 mpn_print (dx+1, size);
204 printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy);
205 mpn_print (dy+1, size);
213 mpn_print (mp_ptr p, mp_size_t size)
217 for (i = size - 1; i >= 0; i--)
219 printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]);