Re: File I/O performance pitfalls

2019-10-25 Thread 9898287 via Digitalmars-d-learn
On Saturday, 26 October 2019 at 02:42:04 UTC, rikki cattermole wrote: On 26/10/2019 2:27 PM, 9898287 wrote: [...] You probably want -O3 not -O5. [...] I assume what you intended is: writeln("Hello, ", i); Also for format functions in D you should prefer the templated variation as it

Re: File I/O performance pitfalls

2019-10-25 Thread rikki cattermole via Digitalmars-d-learn
On 26/10/2019 2:27 PM, 9898287 wrote: Hi I want to find out what's causing my file writes to be so slow. I'm setting up buffer and locking the file and writing them to the file. $ cat d.d && ldc2 -O5  d.d && time ./d >> /dev/null You probably want -O3 not -O5. void main() {     import

File I/O performance pitfalls

2019-10-25 Thread 9898287 via Digitalmars-d-learn
Hi I want to find out what's causing my file writes to be so slow. I'm setting up buffer and locking the file and writing them to the file. $ cat d.d && ldc2 -O5 d.d && time ./d >> /dev/null void main() { import std.stdio; stdout.setvbuf(4096); stdout.lock(); foreach(i; 0 ..

Re: vibed - blocking file I/O via library?

2015-04-07 Thread Sönke Ludwig via Digitalmars-d-learn
- the small server app calls library code to retrieve data for a selected series from a large data store (several files, each up to 45G). This library code uses the standard C/posix APIs for file I/O so isn't written with asynchronous access in mind What do I need to do to make sure

Re: vibed - blocking file I/O via library?

2015-04-07 Thread Laeeth Isharc via Digitalmars-d-learn
You should start a worker thread for this and then use message passing (vibe.core.concurrency) to wait for the results (or alternatively a TaskCondition). I was thinking about including a generic thread proxy in vibe.d that I've used to encapsulate these details when working with libgit in a

vibed - blocking file I/O via library?

2015-04-06 Thread Laeeth Isharc via Digitalmars-d-learn
to retrieve data for a selected series from a large data store (several files, each up to 45G). This library code uses the standard C/posix APIs for file I/O so isn't written with asynchronous access in mind What do I need to do to make sure that if the library code to retrieve the data takes

Re: File I/O - rawWrite issues

2013-05-15 Thread 1100110
On 05/08/2013 07:29 PM, H. S. Teoh wrote: No need to be embarrassed; it happens to the best of us. IME, some of the most frustrating, hair-pulling bugs that take hours (or days!) to get to the bottom of often turn out to be dead-easy trivial mistakes that got overlooked because they were

File I/O - rawWrite issues

2013-05-08 Thread Carl
I am learning D so I thought this would be the correct place for this question (I assume I am making an error, not the compiler). I am writing arrays of ubytes using rawWrite to a file. Whenever I write arrays full of numbers I have no problems, but once I write an array with zeroes I can

Re: File I/O - rawWrite issues

2013-05-08 Thread Meta
For example: ubyte[] data = [5, 34, 9, 45]; file.rawWrite(data); // OKAY ubyte[] data = [0, 0, 0, 45]; file.rawWrite(data); // NOT OKAY Since ubytes are pretty much the same as chars, I think writing 0 to the file will actually write the null character, which probably isn't a good thing.

Re: File I/O - rawWrite issues

2013-05-08 Thread Ali Çehreli
On 05/08/2013 02:46 PM, Meta wrote: For example: ubyte[] data = [5, 34, 9, 45]; file.rawWrite(data); // OKAY ubyte[] data = [0, 0, 0, 45]; file.rawWrite(data); // NOT OKAY Since ubytes are pretty much the same as chars, True from the point of view of sizes: they are both 8-bit wide.

Re: File I/O - rawWrite issues

2013-05-08 Thread Carl
Wow, I feel silly. In the process of making sample code I found the problem: I have been reading the output with a text editor instead of a hex editor. To think I spent hours on this problem... *face palm* Thanks for your quick replies.

Re: File I/O - rawWrite issues

2013-05-08 Thread Idan Arye
On Wednesday, 8 May 2013 at 21:34:00 UTC, Carl wrote: I am learning D so I thought this would be the correct place for this question (I assume I am making an error, not the compiler). I am writing arrays of ubytes using rawWrite to a file. Whenever I write arrays full of numbers I have no

Re: File I/O - rawWrite issues

2013-05-08 Thread H. S. Teoh
On Thu, May 09, 2013 at 01:11:00AM +0200, Carl wrote: Wow, I feel silly. In the process of making sample code I found the problem: I have been reading the output with a text editor instead of a hex editor. To think I spent hours on this problem... *face palm* [...] No need to be

Re: FIle I/O

2010-09-18 Thread Graham Nicholls
Thanks. I figured that it was a duplicate definition, but not if I leave out st.stream, then OpenException is undefined. Is there a documentation for the exceptions which are in the relevant packages - I'll struggle without it! And thanks, all for the help - much appreciated. BTW, am I making

Re: FIle I/O

2010-09-18 Thread Jonathan M Davis
On Saturday 18 September 2010 08:50:41 Graham Nicholls wrote: Thanks. I figured that it was a duplicate definition, but not if I leave out st.stream, then OpenException is undefined. Is there a documentation for the exceptions which are in the relevant packages - I'll struggle without it!

Re: FIle I/O

2010-09-17 Thread Graham Nicholls
I'm getting a little confused. I've installed a .deb package of d 2.0, but now my code won't compile: unlogcat.d(112): Error: std.stream.File at /usr/include/d/dmd/phobos/std/stream.d(1787) conflicts with std.stdio.File at /usr/include/d/dmd/phobos/std/stdio.d(248) Yet if I leave either out, I

Re: FIle I/O

2010-09-17 Thread Steven Schveighoffer
On Fri, 17 Sep 2010 12:21:07 -0400, Graham Nicholls gra...@rockcons.co.uk wrote: I'm getting a little confused. I've installed a .deb package of d 2.0, but now my code won't compile: unlogcat.d(112): Error: std.stream.File at /usr/include/d/dmd/phobos/std/stream.d(1787) conflicts with

Re: FIle I/O

2010-09-17 Thread Jonathan M Davis
On Friday, September 17, 2010 09:21:07 Graham Nicholls wrote: I'm getting a little confused. I've installed a .deb package of d 2.0, but now my code won't compile: unlogcat.d(112): Error: std.stream.File at /usr/include/d/dmd/phobos/std/stream.d(1787) conflicts with std.stdio.File at

FIle I/O

2010-09-16 Thread Graham Nicholls
I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use. If I get it right, this will allow me to replay the file into the system. However I can't find how to do I/O in D. I've got the D Programming Language and Tango

Re: FIle I/O

2010-09-16 Thread Tom Kazimiers
Hi Graham, On 09/16/2010 04:28 PM, Graham Nicholls wrote: I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use. If I get it right, this will allow me to replay the file into the system. However I can't find how

Re: FIle I/O

2010-09-16 Thread Graham Nicholls
Thanks. Not sure how I didn't find that - I'm looking now. Graham

Re: FIle I/O

2010-09-16 Thread Graham Nicholls
Is this D 1.0 ? I get errors regarding printf - I understood that writeln was the 2.0 way. Thanks

Re: FIle I/O

2010-09-16 Thread Tom Kazimiers
Graham, On 09/16/2010 05:02 PM, Graham Nicholls wrote: Is this D 1.0 ? I get errors regarding printf - I understood that writeln was the 2.0 way. Yes, I think it's D 1.0. For a D 2.0 version I replaced those printf's with writeln's, too. Bye, Tom

Re: FIle I/O

2010-09-16 Thread Nick Sabalausky
Graham Nicholls gra...@rockcons.co.uk wrote in message news:i6t9ig$1ff...@digitalmars.com... I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use. If I get it right, this will allow me to replay the file into

Re: FIle I/O

2010-09-16 Thread Kagamin
Tom Kazimiers Wrote: Hi Graham, On 09/16/2010 04:28 PM, Graham Nicholls wrote: I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use. If I get it right, this will allow me to replay the file into the

Re: FIle I/O

2010-09-16 Thread Jonathan M Davis
On Thursday, September 16, 2010 13:16:03 Kagamin wrote: Tom Kazimiers Wrote: Hi Graham, On 09/16/2010 04:28 PM, Graham Nicholls wrote: I'm writing a program to take a file and convert it into a binary format which matches the format produced by a system which we use. If I get it

Basic file i/o

2009-09-11 Thread Ali Cehreli
What is the simplest way of using a file? There are two 'File's in Phobos and they conflict: 1) struct File in std.stdio 2) class File in std.stream The one in std.stream.File is definitely what I want to use. What to do? Prefer using full names in D as in std.stream.File? Perhaps std.stdio

Re: Basic file i/o

2009-09-11 Thread Stewart Gordon
Ali Cehreli wrote: What is the simplest way of using a file? There are two 'File's in Phobos and they conflict: 1) struct File in std.stdio 2) class File in std.stream That's crazy. The one in std.stream.File is definitely what I want to use. What to do? Import std.stream, create a File