Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 15, 2004 default initialisers | ||||
---|---|---|---|---|
| ||||
how good is dmd at optimising away the default initialisers when it is guaranteed that a variable will be initialised later than the variable declaration? I am concerned about this because my program is very time critical. I think it would be cool if there was an attribute for variable declarations not to be initialised by default. |
April 16, 2004 Re: default initialisers | ||||
---|---|---|---|---|
| ||||
Posted in reply to imr1984 | "imr1984" <imr1984_member@pathlink.com> wrote in message news:c5mttq$la8$1@digitaldaemon.com... > how good is dmd at optimising away the default initialisers when it is guaranteed that a variable will be initialised later than the variable declaration? I am concerned about this because my program is very time critical. > I think it would be cool if there was an attribute for variable declarations not > to be initialised by default. But if they arent given a default value, dont they then just contain garbage anyway? If so, isnt it better to have a default value? Phill. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.659 / Virus Database: 423 - Release Date: 4/15/2004 |
April 16, 2004 Re: default initialisers | ||||
---|---|---|---|---|
| ||||
Posted in reply to imr1984 | "imr1984" <imr1984_member@pathlink.com> wrote in message news:c5mttq$la8$1@digitaldaemon.com... > how good is dmd at optimising away the default initialisers when it is guaranteed that a variable will be initialised later than the variable declaration? I am concerned about this because my program is very time critical. > I think it would be cool if there was an attribute for variable declarations not > to be initialised by default. The compiler uses 'data flow analysis' to detect and remove dead assignments, and it works reasonably well. Try it and see. |
April 19, 2004 Re: default initialisers | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> The compiler uses 'data flow analysis' to detect and remove dead assignments, and it works reasonably well. Try it and see.
WinXP dmd 0.82
<code>
import std.c.windows.windows;
void main(){
double dtime(){
return (cast(double) GetTickCount) / 1000;
}
const long size=1_400_000_000;
double start= dtime;
int[] arr=new int[size/4];
//arr[1]=1;
double end= dtime;
printf("%20.20f\n", end - start);
}
</code>
Although I commented the access out, the runtime stays by more than 1.5 seconds, whereas the according C program hushes by.
So long!
|
Copyright © 1999-2021 by the D Language Foundation