my first D program (and benchmark against perl)

2015-11-11 Thread perlancar via Digitalmars-d-learn
Here's my first non-hello-world D program, which is a direct translation from the Perl version. I was trying to get a feel about D's performance: ---BEGIN asciitable.d--- import std.string; import std.stdio; string fmttable(ref string[][] table) { string res = ""; // column widths

Re: my first D program (and benchmark against perl)

2015-11-12 Thread perlancar via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 14:26:32 UTC, Andrea Fontana wrote: Did you try rdmd -O -noboundscheck -release yourscript.d ? I just did. It improves speed from 17.127s to 14.831s. Nice, but nowhere near gdc/ldc level. You should try using appender!string rather than concatenate (http://

Re: my first D program (and benchmark against perl)

2015-11-12 Thread perlancar via Digitalmars-d-learn
On Wednesday, 11 November 2015 at 14:20:51 UTC, Rikki Cattermole wrote: I turned it into mostly using large allocations, instead of small ones. Although I'd recommend using Appender instead of my custom functions for this. Oh and for me, I got it at 2 secs, 513 ms, 397 μs, and 5 hnsecs. Unopt

Re: my first D program (and benchmark against perl)

2015-11-12 Thread perlancar via Digitalmars-d-learn
On Thursday, 12 November 2015 at 12:49:55 UTC, Daniel Kozak wrote: dmd -O -release -inline -boundscheck=off asciitable.d real0m1.463s user0m1.453s sys 0m0.003s ldc2 -singleobj -release -O3 -boundscheck=off asciitable.d real0m0.945s user0m0.940s sys 0m0.000s gdc -O3 -