After reading
https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/
, i was wondering how fast one can do a simple "wc -l" in D.
So i made a couple short implementations and found myself
confronted with slow results compared to "/usr/bin/wc -l".
How would a implementation look li
On Tuesday, 30 May 2017 at 20:02:38 UTC, Nitram wrote:
After reading
https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D.
So i made a couple short implementations and found myself
confronted with slow results compared to
On Tuesday, 30 May 2017 at 20:37:44 UTC, Jordan Wilson wrote:
On Tuesday, 30 May 2017 at 20:02:38 UTC, Nitram wrote:
After reading
https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D.
So i made a couple short implementat
I do not know this is my first attempt and it is almost same fast as wc
on my pc:
int main(string[] args)
{
import std.stdio : writeln, writefln, File;
import std.array : uninitializedArray;
auto f = File("data");
size_t c = 0;
auto buffer = uninitializedArray!(ubyte[])(1024
On Tue, May 30, 2017 at 08:02:38PM +, Nitram via Digitalmars-d-learn wrote:
> After reading
> https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i
> was wondering how fast one can do a simple "wc -l" in D.
>
> So i made a couple short implementations and found myself confronte
On 05/30/2017 01:02 PM, Nitram wrote:
After reading
https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i
was wondering how fast one can do a simple "wc -l" in D.
So i made a couple short implementations and found myself confronted
with slow results compared to "/usr/bin/wc -l".
P.S. After I posted the code, I took a closer look at the disassembly
and found that gdc wasn't generating the best code for the parallel
foreach loop body. I haven't fully traced the cause yet, but I did find
a simple optimization (arguably a micro-optimization): updating the
subtotal inside the
On Tuesday, 30 May 2017 at 23:41:01 UTC, H. S. Teoh wrote:
This little challenge piqued my interest. So I decided to take
a shot at seeing if I could beat my system's /usr/bin/wc -l.
First order of business: whenever it comes to performance,
always choose the right compiler for the job...
Dne 31.5.2017 v 02:13 Ali Çehreli via Digitalmars-d-learn napsal(a):
I could not make the D program come close to wc's performance when the
data was piped from stdin. A typical run with Daniel Kozak's program:
$ time cat deleteme.txt | wc -l
5062176
real0m0.086s
user0m0.068s
sys0m
On 05/30/2017 11:50 PM, Daniel Kozak via Digitalmars-d-learn wrote:
> How do you compile it? When I use ldc2 -O3 -release -mcpu=bdver1 lc.d
> my code is even faster than wc
My bad: I'm not familiar with ldc's optimization options. (I used -O3
but not -release) Now I get the same performance as
On Wednesday, 31 May 2017 at 17:23:46 UTC, Ali Çehreli wrote:
On 05/30/2017 11:50 PM, Daniel Kozak via Digitalmars-d-learn
wrote:
> How do you compile it? When I use ldc2 -O3 -release
-mcpu=bdver1 lc.d
> my code is even faster than wc
My bad: I'm not familiar with ldc's optimization options.
On Tue, May 30, 2017 at 05:13:46PM -0700, Ali Çehreli via Digitalmars-d-learn
wrote:
[...]
> I could not make the D program come close to wc's performance when the
> data was piped from stdin.
[...]
Hmm. This is a particularly interesting case, because I adapted some of
my algorithms to handle re
On Tuesday, 30 May 2017 at 23:41:01 UTC, H. S. Teoh wrote:
On Tue, May 30, 2017 at 08:02:38PM +, Nitram via
Digitalmars-d-learn wrote:
After reading
https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ , i was wondering how fast one can do a simple "wc -l" in D.
size_t lineCo
I am glad to see this participation on this issue :)
The hints about trying another compiler and std.mmfile turned out
to be very effective.
Even this simple code is faster then my systems "wc -l" now:
void main() {
import std.stdio;
writeln(lcs("benchmark.dat"));
}
size_t lcs
On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn
wrote:
> I did some digging around, and it seems that wc is using glibc's memchr,
> which is highly-optimized, whereas std.algorithm.count just uses a
> simplistic loop. Which is strange, because I'm pretty sure somebody
> opti
On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via
Digitalmars-d-learn wrote:
> On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn
> wrote:
> > I did some digging around, and it seems that wc is using glibc's
> > memchr, which is highly-optimized, whereas std.algor
On Tue, 2017-05-30 at 17:22 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
> […]
> performance in a significant way. But I thought this might be a
> useful
> tip for people who want to squeeze out the last drop of juice from
> their
> CPUs. ;-)
>
[…]
I have the beginnings of wc written in vari
On Thu, Jun 01, 2017 at 12:20:53AM +0100, Russel Winder via Digitalmars-d-learn
wrote:
[...]
> However, I note here that the Chapel folk are taking a quite
> interesting view of algorithm implementation in the Benchmarks Game.
> They are totally eschewing "heroic implementations" such as all the C
On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via Digitalmars-d-learn
wrote:
> On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via
Digitalmars-d-learn wrote:
> > On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via Digitalmars-d-learn
> >
> > wrote:
> > > I did some digging around, and
On Wednesday, 31 May 2017 at 23:03:54 UTC, H. S. Teoh wrote:
On Wed, May 31, 2017 at 03:46:17PM -0700, Jonathan M Davis via
Digitalmars-d-learn wrote:
On Wednesday, May 31, 2017 12:13:04 H. S. Teoh via
Digitalmars-d-learn wrote:
> I did some digging around, and it seems that wc is using
> glibc
On Thursday, 1 June 2017 at 04:39:17 UTC, Jonathan M Davis wrote:
On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via
Digitalmars-d-learn wrote:
[...]
Digitalmars-d-learn wrote:
[...]
If you're really trying to make it fast, there may be something
that you can do with SIMD. IIRC, Brian Schot
On Thursday, June 01, 2017 04:52:40 Patrick Schluter via Digitalmars-d-learn
wrote:
> On Thursday, 1 June 2017 at 04:39:17 UTC, Jonathan M Davis wrote:
> > On Wednesday, May 31, 2017 16:03:54 H. S. Teoh via
> >
> > Digitalmars-d-learn wrote:
> >> [...]
> >
> > Digitalmars-d-learn wrote:
> >> [...]
On Wed, May 31, 2017 at 10:05:50PM -0700, Jonathan M Davis via
Digitalmars-d-learn wrote:
> On Thursday, June 01, 2017 04:52:40 Patrick Schluter via Digitalmars-d-learn
[...]
> > See my link above to realdworldtech. Using SIMD can give good
> > results in micro-benchmarks but completely screw up
On Wednesday, May 31, 2017 22:50:19 H. S. Teoh via Digitalmars-d-learn
wrote:
> Perhaps the right approach is to check if the array length is less than
> some arbitrary threshold, and just use a naïve loop below that, and only
> switch to the complicated hackish stuff where you're sure it will
> a
On Wed, 2017-05-31 at 16:37 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
>
[…]
> With D, we can have the cake and eat it too. The understandable /
> naïve
> implementation can be available as a fallback (and reference
> implementation), with OS-specific optimized implementations guarded
> und
On Wed, May 31, 2017 at 12:13:04PM -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
> On Tue, May 30, 2017 at 05:13:46PM -0700, Ali Çehreli via Digitalmars-d-learn
> wrote:
> [...]
> > I could not make the D program come close to wc's performance when the
> > data was piped from stdin.
> [...]
>
On Thu, Jun 01, 2017 at 08:39:07AM +0100, Russel Winder via Digitalmars-d-learn
wrote:
> On Wed, 2017-05-31 at 16:37 -0700, H. S. Teoh via Digitalmars-d-learn
> wrote:
> >
> […]
> > With D, we can have the cake and eat it too. The understandable /
> > naïve implementation can be available as a f
On Fri, 2017-06-02 at 10:32 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
> […]
>
> Also, compiler implementors do still have to do the "heroics", or
> rather, teach the compiler to do the "heroics" when compiling
> straightforward code. So while the general programmer probably will
> have
> le
On Sat, Jun 03, 2017 at 07:00:47AM +0100, Russel Winder via Digitalmars-d-learn
wrote:
[...]
> There are many different sorts of programming. Operating systems,
> compilers, GUIs, Web services, machine learning, etc., etc. all
> require different techniques. Also there are always new areas, where
On Wed, 2017-05-31 at 16:37 -0700, H. S. Teoh via Digitalmars-d-learn
wrote:
> […]
>
> An even more down-to-earth counterargument is that if CPU vendors had
> been content with understandable, simple CPU implementations, and
> eschewed "heroic", hard-to-understand things like instruction
> pipelin
30 matches
Mail list logo