Forum > General

[SOLVED] Speed-up masive file writing.

<< < (2/3) > >>

Phil:

--- Quote from: Laksen on August 23, 2016, 03:29:45 am ---Try this. Much simpler and much faster

--- End quote ---

Yes, that's the way I would write it.

Question: Does SetTextBuf make much of a difference in performance? That was a common trick years ago, but I'm wondering if modern OS buffering reduces its effect.

miki:
Ok, people, sumary (all test in SSD drive):

My last approach: 580~610ms
Phil's approach: 620~630ms
johnsson's approach: 460~480ms (the result is wrong)
Lanksen's approach: 435ms (Phil's + SetTextBuf)

Notes:
Yes, it seems SetTextBuf makes a difference. I don't like the remarks in docs, but it's the fastest!
Phil's approach: faster now? yes, I made a profiling error yesterday, sorry for that.
johnsson's: what is wrong? The line "Move(LineEnding...)" didn't compile for some reason. I guess we are using different OS, and this constant may be a string for you and a char for me. I made a little change in the code to make it work, but introduced some mistake, because the final file is a bit bigger and has broken line breaks [get the joke? broken breaks]. Anyways, very fast, too.

Lots of thanks to all of you.

Regards.

Phil:

--- Quote from: miki on August 23, 2016, 08:42:59 pm ---Yes, it seems SetTextBuf makes a difference. I don't like the remarks in docs, but it's the fastest!

--- End quote ---

I would say the remarks are just common sense; Laksen's code is safe.

Good to know that SetTextBuf is still useful.

marcov:
Default the buffer is 128 bytes for historical reasons.

So yes it saves something. Setting it above 32kb is never noticable, and typically 8kb is already enough.

User137:
Is there a typo in the docs? http://www.freepascal.org/docs-html/rtl/system/settextbuf.html


--- Quote ---The maximum size of the newly assigned buffer is 65355 bytes.
--- End quote ---
Should be 65535? (2^16 - 1)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version