math.log() benchmark of first 1 billion int using std.parallelism
aldanor via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 22 03:11:06 PST 2014
On Monday, 22 December 2014 at 10:40:45 UTC, Daniel Kozak wrote:
> On Monday, 22 December 2014 at 10:35:52 UTC, Daniel Kozak via
> Digitalmars-d-learn wrote:
>>
>>> I run Arch Linux on my PC. I compiled D programs using
>>> dmd-2.066 and used no compile arguments (dmd prog.d)
>>
>> You should try use some arguments -O -release -inline
>> -noboundscheck
>> and maybe try use gdc or ldc should help with performance
>>
>> can you post your code in all languages somewhere? I like to
>> try it on
>> my machine :)
>
> Btw. try use C log function, maybe it would be faster:
>
> import core.stdc.math;
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
More information about the Digitalmars-d-learn
mailing list