[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / builtins / timing / divdi3.c
blob37937aab624bd5c97e8d46a6fcb5350c5c9afb62
1 #include "timing.h"
2 #include <stdio.h>
4 #define INPUT_TYPE int64_t
5 #define INPUT_SIZE 256
6 #define FUNCTION_NAME __divdi3
8 #ifndef LIBNAME
9 #define LIBNAME UNKNOWN
10 #endif
12 #define LIBSTRING LIBSTRINGX(LIBNAME)
13 #define LIBSTRINGX(a) LIBSTRINGXX(a)
14 #define LIBSTRINGXX(a) #a
16 INPUT_TYPE FUNCTION_NAME(INPUT_TYPE input1, INPUT_TYPE input2);
18 int main(int argc, char *argv[]) {
19 INPUT_TYPE input1[INPUT_SIZE];
20 INPUT_TYPE input2[INPUT_SIZE];
21 int i, j;
23 srand(42);
25 // Initialize the input array with data of various sizes.
26 for (i=0; i<INPUT_SIZE; ++i) {
27 input1[i] = (((int64_t)rand() << 36) | (uint64_t)rand()) >> (rand() & 63);
28 input2[i] = ((((int64_t)rand() << 36) | (uint64_t)rand()) >> (rand() & 63)) + 1LL;
31 int64_t fixedInput = INT64_C(0x1234567890ABCDEF);
33 double bestTime = __builtin_inf();
34 void *dummyp;
35 for (j=0; j<1024; ++j) {
37 uint64_t startTime = mach_absolute_time();
38 for (i=0; i<INPUT_SIZE; ++i)
39 FUNCTION_NAME(input1[i], input2[i]);
40 uint64_t endTime = mach_absolute_time();
42 double thisTime = intervalInCycles(startTime, endTime);
43 bestTime = __builtin_fmin(thisTime, bestTime);
45 // Move the stack alignment between trials to eliminate (mostly) aliasing effects
46 dummyp = alloca(1);
49 printf("%16s: %f cycles.\n", LIBSTRING, bestTime / (double) INPUT_SIZE);
51 return 0;