On Monday, 22 December 2014 at 11:11:07 UTC, aldanor wrote:
Just tried it out myself (E5 Xeon / Linux):
D version: 19.64 sec (avg 3 runs)
import core.stdc.math;
void main() {
double s = 0;
foreach (i; 1 .. 1_000_000_000)
s += log(i);
}
// build flags: -O -release
C version: 19.80 sec (avg 3 runs)
#include <math.h>
int main() {
double s = 0;
long i;
for (i = 1; i < 1000000000; i++)
s += log(i);
return 0;
}
// build flags: -O3 -lm
Replacing "import core.stdc.math" with "import std.math" in the D
example increases the avg runtime from 19.64 to 23.87 seconds
(~20% slower) which is consistent with OP's statement.