[Issue 255] New: Odd performance difference w/ complex doubles.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jul 16 18:34:46 PDT 2006
http://d.puremagic.com/issues/show_bug.cgi?id=255
Summary: Odd performance difference w/ complex doubles.
Product: D
Version: 0.162
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: godaves at yahoo.com
Version foo runs 5x slower depending on which scope the complex double
variables are declared in.
import std.stdio, std.string;
void main(char[][] args)
{
char bit_num = 0, byte_acc = 0;
const int iter = 50;
const double lim = 2.0 * 2.0;
version(foo)
{
cdouble Z, C;
}
int n = atoi(args[1]);
writefln("P4\n%d %d",n,n);
for(int y=0; y<n; y++)
for(int x=0; x<n; x++)
{
version(foo)
{}
else
{
cdouble Z,C;
}
Z = 0 + 0i;
C = 2*cast(double)x/n - 1.5 + 2i*cast(double)y/n - 1i;
for(int i = 0; i < iter && norm(Z) <= lim; i++)
Z = Z*Z + C;
byte_acc = (byte_acc << 1) | ((norm(Z) > lim) ? 0x00:0x01);
bit_num++;
if(bit_num == 8)
{
putc(byte_acc,stdout);
bit_num = byte_acc = 0;
}
else if(x == n-1)
{
byte_acc <<= (8-n%8);
putc(byte_acc,stdout);
bit_num = byte_acc = 0;
}
}
}
double norm(cdouble C)
{
return C.re*C.re + C.im*C.im;
}
--
More information about the Digitalmars-d-bugs
mailing list