some regex vs std.ascii vs handcode times

Martin Nowak dawg at dawgfoto.de
Wed Mar 21 01:25:47 PDT 2012


On Mon, 19 Mar 2012 08:56:28 +0100, Dmitry Olshansky  
<dmitry.olsh at gmail.com> wrote:

> There doesn't appear to be any significant overhead to reading dchar vs
> char. I haven't looked at the code (or decode) underneath. I presume it
> is decoding and expanding into dchar...
>  // read dchar lc by chunk ...same
> //finished! time: 34 ms
> void wcp_dchar(string fn)
> {
> ulong l_cnt;
> auto f = File(fn);
> foreach(chunk; f.byChunk(1_000_000)){
> foreach(dchar c;chunk){
> if (c=='\n')
> l_cnt++;
> }
> }
> }
>  That was strange - decoding takes time, that surely trips few msesc in  
> favor of non-decoding version. Probably I/o is hiding the facts here.

1.5x-3x and we haven't even ported back the faster phobos
std.utf.decode to druntime which is called by foreach.


More information about the Digitalmars-d mailing list