Java > Scala
bearophile
bearophileHUGS at lycos.com
Fri Dec 2 01:35:10 PST 2011
David Eagen:
> So, it's nearly twice as fast but still the slowest of the four.
I guess that a Python program too will be faster than the D code.
Your D code looks good enough now. The problem is that to create fast programs you need well tuned libraries and a good compiler back-end, and this requires lot of work and time. Currently steering too much D development efforts toward tuning is a bad idea because there are several more important issues, even design ones (like applying the already written patches present in GitHug).
Cosmetic matters about your code:
args[1 .. args.length] ==> args[1 .. $]
endsWith(hostName, "foo.com") ==> hostName.endsWith("foo.com")
Now I suggest to compile your D program with:
- O -release -inline -profile
and run it on a smaller input (because it will run slower or much slower).
rename the profiling output files (otherwise they get corrupted, I don't know if this problem is in bugzilla), and profile it again with:
- O -release -profile
Taking a look at the profiler output will help find where the problems are. Maybe that profiling will generate material for a Bugzilla entry too.
If you also want to try disabling the GC in the inflationary phase of the program:
import core.memory: GC;
...
GC.disable();
foreach (arg; args[1 .. args.length])
...
GC.enable();
/* Sort the host names */
...
Bye,
bearophile
More information about the Digitalmars-d
mailing list