[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gcl-devel] mv
From: |
Camm Maguire |
Subject: |
[Gcl-devel] mv |
Date: |
21 Apr 2006 18:27:49 -0400 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Greetings! Here is a sample of what gains might be had:
=============================================================================
#include <stdio.h>
#include <sys/time.h>
#include <time.h>
int vs_base[2],*vs_top=vs_base;
int
foo(int x) {
*vs_top++=x;
return x+x;
}
int
foo1(int x,int *y) {
*y=x;
return x+x;
}
void
test(int (*f)(int),int (*f1)(int,int *)) {
struct timeval tv,tv1;
int k,i,j[1000000],l;
gettimeofday(&tv,NULL);
for (k=0;k<1000;k++)
for (i=0;i<1000000;i++) {
vs_top=vs_base;
j[i]=f(i);
if (vs_top>vs_base)
j[i]+=--*vs_top;
}
gettimeofday(&tv1,NULL);
printf("%f\n",(1000000.0*(tv1.tv_sec-tv.tv_sec)+(tv1.tv_usec-tv.tv_usec)));
gettimeofday(&tv,NULL);
for (k=0;k<1000;k++)
for (i=0;i<1000000;i++) {
j[i]=f1(i,&l);
j[i]+=l;
}
gettimeofday(&tv1,NULL);
printf("%f\n",(1000000.0*(tv1.tv_sec-tv.tv_sec)+(tv1.tv_usec-tv.tv_usec)));
}
int
main() {
test(foo,foo1);
return 0;
}
=============================================================================
cc -O3 tty1.c -o tty1
./tty1
8431383.000000
6823606.000000
Take care,
--
Camm Maguire address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gcl-devel] mv,
Camm Maguire <=