Can I speed up this log parsing script further?

2017-06-09 Thread uncorroded via Digitalmars-d-learn
Hi guys, I am a beginner in D. As a project, I converted a log-parsing script in Python which we use at work, to D. This link was helpful - ( https://dlang.org/blog/2017/05/24/faster-command-line-tools-in-d/ ) I compiled it with dmd and ldc. The log file is 52 MB. With dmd (not release build

Re: Can I speed up this log parsing script further?

2017-06-09 Thread uncorroded via Digitalmars-d-learn
On Friday, 9 June 2017 at 08:58:38 UTC, Daniel Kozak wrote: There is no difference in speed because you do not process your data lazily, so you make many allocations, so this is main reason why it is so slow. I could improve that, but I will need to see some example data, which you are trying

Re: Can I speed up this log parsing script further?

2017-06-09 Thread uncorroded via Digitalmars-d-learn
On Friday, 9 June 2017 at 14:19:48 UTC, Daniel Kozak wrote: import std.stdio; import std.array: appender, array; import std.algorithm : findSplit, splitter, joiner, canFind, map; import std.typecons : tuple, Tuple; import std.conv : to; import std.range : dropOne, dropExactly, takeExactly, chai

Using array slices with C-style fread() from file

2017-06-21 Thread uncorroded via Digitalmars-d-learn
Hi all, I am writing a program to read device /dev/urandom file to get some random bytes. I am trying to bypass D's GC as I know the length of the buffer needed. I tried using std.stdio.File and rawRead but File cannot be used with @nogc. So I used core.stdc.stdio and used traditional C style

Re: Using array slices with C-style fread() from file

2017-06-21 Thread uncorroded via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 18:58:58 UTC, tetyys wrote: On Wednesday, 21 June 2017 at 18:49:01 UTC, uncorroded wrote: Is there a way of making this work with D slices? Can they be used as C-style pointers? What about this: @nogc ubyte[n] rand_bytes(uint n)() { import core.stdc.stdio;

Re: Using array slices with C-style fread() from file

2017-06-21 Thread uncorroded via Digitalmars-d-learn
On Wednesday, 21 June 2017 at 19:11:44 UTC, Ali Çehreli wrote: On 06/21/2017 12:06 PM, uncorroded wrote: > Is > there any way of making the function with @safe as well? I get the > errors "cannot call @system function 'core.stdc.stdio.fread,fopen,fclose'. @trusted is exactly for that. It can be