Inlining Code Test
bearophile
bearophileHUGS at lycos.com
Fri Dec 17 14:57:44 PST 2010
Nick Voronin:
> Looks like alignment of local variables is somewhat broken.
This is a very nice bug. If not already present then please add it to Bugzilla. If you don't want to add it, then I will add it myself. I have modified your code like this:
import core.stdc.stdio: printf;
void main() {
int a;
double d;
printf("%u %u\n", (cast(size_t)&a) % 8, (cast(size_t)&d) % 8);
}
And this shows the performance difference:
import core.stdc.stdio: printf;
import std.date: getUTCtime, ticksPerSecond;
void main() {
double d = 0.0;
auto t0 = getUTCtime();
for (size_t i = 0; i < 100_000_000; i++)
d += 1;
auto t1 = getUTCtime();
printf("%lf\n", d);
printf("%u\n", (cast(size_t)&d) % 8);
printf("%lf\n", (cast(double)t1 - cast(double)t0) / ticksPerSecond);
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list