Slow start up time of runtime

Dennis dkorpel at gmail.com
Tue Mar 20 10:20:55 UTC 2018


On Tuesday, 20 March 2018 at 09:51:09 UTC, bauss wrote:
> Besides if it was and it took 1 second to startup, then it 
> wouldn't matter in practice with an actual application.

This is not concerning for large applications indeed. But say, I 
want to implement my own `dir` (= `ls` on Unix) in D. Would you 
want to use it if it took a full second every time you wanted to 
quickly view a folder's contents?

On Tuesday, 20 March 2018 at 09:51:09 UTC, bauss wrote:
> Without actual compiler versions, compiler flags and example 
> code then it's pretty much impossible to tell what's slow.

```
import core.stdc.stdio: printf;

int main() {
	return printf("hello world");
}
```
Compiling with `dmd helloworld_printf.d` or `dmd -release -O 
-inline helloworld_printf.d` doesn't make a difference here: 
`Measure-Command {./helloworld_printf}` reports ~1.1s in any 
case.  I'm using 2.079 but I doubt this is a regression.

betterC version:
```
import core.stdc.stdio: printf;

extern(C) int main() {
	return printf("hello world");
}
```
`dmd helloworld_betterc.d -betterC`
`ldc2 helloworld_betterc.d -betterC`

I now notice that without the -betterC flag it's also 0.05s. So I 
suppose defining a `_d_run_main` instead of a `extern(C) main` is 
causing the slow startup time.


More information about the Digitalmars-d-learn mailing list