Messages in this thread | | | From | Denis Vlasenko <> | Subject | Re: [RFC] cleanup patches for strings | Date | Tue, 21 Jun 2005 16:20:31 +0300 |
| |
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/
| |