lkml.org 
[lkml]   [2005]   [Jun]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [RFC] cleanup patches for strings
Date
Um, prev one was using push %reg. My fault.
push $imm gives the same result:

# gcc -O2 -falign-loops=64 t.c
# ./a.out
Took 9291 CPU cycles Took 8068 CPU cycles
Took 9080 CPU cycles Took 8058 CPU cycles
Took 9134 CPU cycles Took 8061 CPU cycles
Took 9084 CPU cycles Took 8043 CPU cycles
Took 9084 CPU cycles Took 8043 CPU cycles
Took 9084 CPU cycles Took 8043 CPU cycles

The source:

#define rdtscl(low) asm volatile("rdtsc" : "=a" (low) : : "edx")

#define NL "\n"

#include <stdio.h>

int main() {
int i,k,start,end;
int v = 1234;

for(k=0; k<6; k++) {
rdtscl(start);
for(i=0; i<1000; i++) {
asm(NL
" push %0" NL
" pop %%eax" NL
" push %0" NL
" pop %%eax" NL
" push %0" NL
" pop %%eax" NL
" push %0" NL
" pop %%eax" NL
: /* outputs */
: "m" (v) /* inputs */
: "ax" /* clobbers */
);
}
rdtscl(end);
printf("Took %u CPU cycles ", end-start);

rdtscl(start);
for(i=0; i<1000; i++) {
asm(NL
" push $1234" NL
" pop %%eax" NL
" push $1234" NL
" pop %%eax" NL
" push $1234" NL
" pop %%eax" NL
" push $1234" NL
" pop %%eax" NL
: /* outputs */
: /* inputs */
: "ax" /* clobbers */
);
}
rdtscl(end);
printf("Took %u CPU cycles\n", end-start);
}
return 0;
}
--
vda

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-06-21 15:47    [W:0.079 / U:0.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site