As for startup cost, D will indeed have a higher startup cost than C because of static constructors. Once it's running, it should be very close. If you're looking to start a process that will run for only a few milliseconds, you'd probably want to not use D (or avoid most static constructors, including those in the runtime / standard library).
Re: Small part of a program : d and c versions performances diff.
Kapps via Digitalmars-d-learn Wed, 09 Jul 2014 22:07:20 -0700
Measure a larger number of loops. I understand you're concerned
about microseconds, but your benchmark shows nothing because your
timer is simply not accurate enough for this. The benchmark that
bearophile showed where C took ~2 nanoseconds vs the ~7000 D took
heavily implies to me that the C implementation is simply being
optimized out and nothing is actually running. All inputs are
known at compile-time, the output is known at compile-time, the
compiler is perfectly free to simply remove all your code and
replace it with the result. I'm somewhat surprised that the D
version doesn't do this actually, perhaps because of the dynamic
memory allocation. I realize that you can't post your actual
code, but this benchmark honestly just has too many flaws to
determine anything from.
- Re: Small p... Chris via Digitalmars-d-learn
- Re: Small p... John Colvin via Digitalmars-d-learn
- Re: Small p... Larry via Digitalmars-d-learn
- Re: Small p... Larry via Digitalmars-d-learn
- Re: Small part of a program ... Kapps via Digitalmars-d-learn
- Re: Small part of a prog... Larry via Digitalmars-d-learn
- Re: Small part of a program : d and c... Ali Çehreli via Digitalmars-d-learn
- Re: Small part of a program : d ... Larry via Digitalmars-d-learn
- Re: Small part of a program ... Ali Çehreli via Digitalmars-d-learn
- Re: Small part of a prog... Larry via Digitalmars-d-learn
- Re: Small part of a program : d and c... Kapps via Digitalmars-d-learn