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 pro

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 .. 9

Re: Converting a ulong to a byte array and constructing a ulong from it

2019-10-24 Thread 9898287 via Digitalmars-d-learn
On Thursday, 24 October 2019 at 13:50:54 UTC, Paul Backus wrote: On Thursday, 24 October 2019 at 13:33:30 UTC, 9898287 wrote: What's the function for converting a ulong to a native-endian byte array? For example, auto bytes = 0x1234567890123456u64.to_ne_bytes(); // should yield // [0x12, 0x34,

Converting a ulong to a byte array and constructing a ulong from it

2019-10-24 Thread 9898287 via Digitalmars-d-learn
What's the function for converting a ulong to a native-endian byte array? For example, auto bytes = 0x1234567890123456u64.to_ne_bytes(); // should yield // [0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56] in big-endian and // [0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12] in little-endian sy