Mail Archives: djgpp-workers/2001/02/04/05:41:56
Eli Zaretskii writes:
> However, I didn't find any evidence that an int is faster than a char.
> Can you provide such an evidence, e.g., by looking at the code produced
> by gcc 2.9X and counting cycles?
I tried. I was wrong - the difference between two versions is very little.
Here is my "benchmark":
int main(void)
{
unsigned char x, y, z, t, u, v;
for (x = 0; x < 200; x++)
for (y = 0; y < 200; y++)
for (u = 0; u < 200; u++)
for (v = 0; v < 200; v++)
{
z = x * y;
t = z - x / y;
z = t + u;
t = z - u;
}
return 0;
}
Replace 'unsigned char' with 'unsigned int' for int version.
> > > +typedef signed int int_fast16_t;
> > > +typedef unsigned int uint_fast16_t;
> >
> > Likewise there.
>
> Well, these _are_ 32-bit int's, aren't they? ;-)
Ooops. I swear I saw 'short int' there :-)
Laurynas
- Raw text -