Merge #12079: Improve prioritisetransaction test coverage
[bitcoinplatinum.git] / src / bench / perf.h
blob681bd0c8a27e690580254012ac84d95be955a590
1 // Copyright (c) 2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 /** Functions for measurement of CPU cycles */
6 #ifndef H_PERF
7 #define H_PERF
9 #include <stdint.h>
11 #if defined(__i386__)
13 static inline uint64_t perf_cpucycles(void)
15 uint64_t x;
16 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
17 return x;
20 #elif defined(__x86_64__)
22 static inline uint64_t perf_cpucycles(void)
24 uint32_t hi, lo;
25 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
26 return ((uint64_t)lo)|(((uint64_t)hi)<<32);
28 #else
30 uint64_t perf_cpucycles(void);
32 #endif
34 void perf_init(void);
35 void perf_fini(void);
37 #endif // H_PERF