10 #if defined(__LCLINT__) 12 extern int nanosleep(
const struct timespec *__requested_time,
13 struct timespec *__remaining)
34 #if defined(__linux__) && defined(__i386__) && !defined(RPM_VENDOR_PLD) 37 #define HP_TIMING_ZERO(Var) (Var) = (0) 38 #define HP_TIMING_NOW(Var) __asm__ __volatile__ ("rdtsc" : "=A" (Var)) 41 #define HP_TIMING_DIFF(Diff, Start, End) (Diff) = ((End) - (Start)) 44 #define HP_TIMING_ACCUM(Sum, Diff) \ 47 hp_timing_t __oldval = (Sum); \ 48 hp_timing_t __diff = (Diff) - GL(dl_hp_timing_overhead); \ 51 hp_timing_t __newval = __oldval + __diff; \ 52 int __temp0, __temp1; \ 53 __asm__ __volatile__ ("xchgl %4, %%ebx\n\t" \ 54 "lock; cmpxchg8b %1\n\t" \ 57 : "=q" (__not_done), "=m" (Sum), \ 58 "=A" (__oldval), "=c" (__temp0), \ 60 : "1" (Sum), "2" (__oldval), \ 61 "3" (__newval >> 32), \ 62 "4" (__newval & 0xffffffff) \ 69 #define HP_TIMING_ACCUM_NT(Sum, Diff) (Sum) += (Diff) 72 #define HP_TIMING_PRINT(Buf, Len, Val) \ 75 char *__cp = _itoa (Val, __buf + sizeof (__buf), 10, 0); \ 77 char *__dest = (Buf); \ 78 while (__len-- > 0 && __cp < __buf + sizeof (__buf)) \ 79 *__dest++ = *__cp++; \ 80 memcpy (__dest, " clock cycles", MIN (__len, sizeof (" clock cycles"))); \ 92 if (gettimeofday(&sw->
u.
tv, NULL))
95 #if defined(HP_TIMING_NOW) 97 HP_TIMING_NOW(sw->
u.
ticks);
112 const struct timeval * btv)
116 if (etv == NULL || btv == NULL)
return 0;
117 secs = etv->tv_sec - btv->tv_sec;
118 for (usecs = etv->tv_usec - btv->tv_usec; usecs < 0; usecs += 1000000)
120 return (
rpmtime_t) ((secs * 1000000) + usecs);
127 if (end == NULL || begin == NULL)
134 #if defined(HP_TIMING_NOW) 148 #if defined(HP_TIMING_NOW) 155 struct timespec req, rem;
163 req.tv_nsec = 20 * 1000 * 1000;
164 for (i = 0; i < 100; i++) {
165 rc = nanosleep(&req, &rem);
168 if (rem.tv_sec == 0 && rem.tv_nsec == 0)
188 #if defined(HP_TIMING_NOW) 201 for (i = 0; i < 3; i++) {
202 #if defined(HP_TIMING_NOW) 216 cycles = rpmswCalibrate();
219 sum_cycles += cycles;
283 if (to != NULL && from != NULL) {
295 if (to != NULL && from != NULL) {
306 static unsigned int scale = (1000 * 1000);
309 if (op != NULL && op->
count > 0)
310 fprintf(fp,
" %s %8d %6lu.%06lu MB %6lu.%06lu secs\n",
312 (
unsigned long)op->
bytes/scale, (
unsigned long)op->
bytes%scale,
rpmtime_t rpmswExit(rpmop op, ssize_t rc)
Exit timed operation.
static rpmtime_t rpmsw_cycles
rpmtime_t rpmswAdd(rpmop to, rpmop from)
Sum statistic counters.
rpmtime_t rpmswInit(void)
Return benchmark time stamp overhead.
void rpmswPrint(const char *name, rpmop op, FILE *fp)
Print operation statistics.
static rpmtime_t tvsub(const struct timeval *etv, const struct timeval *btv)
Return difference of 2 timeval stamps in micro-seconds.
rpmtime_t rpmswDiff(rpmsw end, rpmsw begin)
Return benchmark time stamp difference.
unsigned long long rpmuint64_t
int rpmswEnter(rpmop op, ssize_t rc)
Enter timed operation.
Cumulative statistics for an operation.
static rpmtime_t rpmsw_overhead
rpmtime_t rpmswSub(rpmop to, rpmop from)
Subtract statistic counters.
unsigned long long int ticks
static int rpmsw_initialized
unsigned long int rpmtime_t
rpmsw rpmswNow(rpmsw sw)
Return benchmark time stamp.