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 [EMAIL PROTECTED]
==========================================================================
"The earth is but one country, and mankind its citizens." -- Baha'u'llah
_______________________________________________
Gcl-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gcl-devel