[AA] Rename CaptureInfo -> CaptureAnalysis (NFC) (#116842)
[llvm-project.git] / compiler-rt / test / builtins / timing / negdi2.c
blob2668eb1e831f385988519e080c1934fc50e5e757
1 #include "timing.h"
2 #include <stdio.h>
4 #define INPUT_TYPE int64_t
5 #define INPUT_SIZE 256
6 #define FUNCTION_NAME __negdi2
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 input);
18 int main(int argc, char *argv[]) {
19 INPUT_TYPE input[INPUT_SIZE];
20 int i, j;
22 srand(42);
24 // Initialize the input array with data of various sizes.
25 for (i=0; i<INPUT_SIZE; ++i) {
26 input[i] = (((int64_t)rand() << 36) | (uint64_t)rand()) >> (rand() & 63);
29 int64_t fixedInput = INT64_C(0x1234567890ABCDEF);
31 double bestTime = __builtin_inf();
32 void *dummyp;
33 for (j=0; j<1024; ++j) {
35 uint64_t startTime = mach_absolute_time();
36 for (i=0; i<INPUT_SIZE; ++i)
37 FUNCTION_NAME(input[i]);
38 uint64_t endTime = mach_absolute_time();
40 double thisTime = intervalInCycles(startTime, endTime);
41 bestTime = __builtin_fmin(thisTime, bestTime);
43 // Move the stack alignment between trials to eliminate (mostly) aliasing effects
44 dummyp = alloca(1);
47 printf("%16s: %f cycles.\n", LIBSTRING, bestTime / (double) INPUT_SIZE);
49 return 0;