Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-07

Getting fast output

10 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

leledumbo

Is there any way so that Write(Ln) doesn't flush the buffer after each call (as if it's called to write to a file, I knew it from rtl's file handling source), but only when Flush is called? I found some maniac's code that does it at assembler level, but of course it's platform dependant (i386-linux only). Currently, I get it through the use of:
TextRec(<TextVar>).FlushFunc:=nil;
but this forces me to use SysUtils which increase the executable size significantly. If this is the only solution, then please move the record to System unit (if possible, with FileRec too).

View this message in context: http://www.nabble.com/Getting-fast-output-tp18562328p18562328.html Sent from the Free Pascal - General mailing list .

Reply by email

Peter Vreman
Show quoted text 10 lines
Is there any way so that Write(Ln) doesn't flush the buffer after each call (as if it's called to write to a file, I knew it from rtl's file handling source), but only when Flush is called? I found some maniac's code that does it at assembler level, but of course it's platform dependant (i386-linux only). Currently, I get it through the use of: TextRec(<TextVar>).FlushFunc:=nil; but this forces me to use SysUtils which increase the executable size significantly. If this is the only solution, then please move the record to System unit (if possible, with FileRec too).

http://www.freepascal.org/docs-html/rtl/system/settextbuf.html

Reply by email

Tomas Hajny
to leledumbo: Is there any way so that Write(Ln) doesn't flush the buffer after each call (as if it's…
leledumbo wrote 13 lines
Is there any way so that Write(Ln) doesn't flush the buffer after each call (as if it's called to write to a file, I knew it from rtl's file handling source), but only when Flush is called? I found some maniac's code that does it at assembler level, but of course it's platform dependant (i386-linux only). Currently, I get it through the use of: TextRec(<TextVar>).FlushFunc:=nil; but this forces me to use SysUtils which increase the executable size significantly. If this is the only solution, then please move the record to System unit (if possible, with FileRec too).

The two record types are declared in unit Dos too; with smartlinking, this unit should cause virtually no overhead.

Tomas

Reply by email

leledumbo
to Peter Vreman: http://www.freepascal.org/docs-html/rtl/system/settextbuf.html
Peter Vreman wrote

Oh, yeah! I forgot to mention this. But declaring the buffer will eat spaces ,for instance:
...
var

  Buf: array [0..65535] of Byte;

...
will add 64k to the executable because it's allocated on the stack.

View this message in context: http://www.nabble.com/Getting-fast-output-tp18562328p18582669.html Sent from the Free Pascal - General mailing list .

Reply by email

Marco van de Voort
to leledumbo: Oh, yeah! I forgot to mention this. But declaring the buffer will eat spaces ,for…
Show quoted text 12 lines
Peter Vreman wrote: > > http://www.freepascal.org/docs-html/rtl/system/settextbuf.html > http://www.freepascal.org/docs-html/rtl/system/settextbuf.html > Oh, yeah! I forgot to mention this. But declaring the buffer will eat spaces ,for instance: ... var Buf: array [0..65535] of Byte; ... will add 64k to the executable because it's allocated on the stack.

Huh?

A filebuffer variable must be available always, so it is a global variable. Global variables are in the datasegment. The datasegment is traditionally divided into two parts, an initialized part (which goes into the binary) and the uninitialized (which doesn't go in the binary).

Since the above variable is not initialized, it will not go into the binary.

Unless your platform is somehow different, but even then you can allocate it on the heap.

Reply by email

Vincent Snijders
to Marco van de Voort
Marco van de Voort wrote 5 lines
> will add 64k to the executable because it's allocated on the stack. Huh? A filebuffer variable must be available always, so it is a global variable.

I thought the file buffer variable must available for the time a file is opened and can be discarded after the file has been closed.

Vincent

Reply by email

Marco van de Voort
to Vincent Snijders
Show quoted text 9 lines
Marco van de Voort schreef: >> will add 64k to the executable because it's allocated on the stack. > > Huh? > > A filebuffer variable must be available always, so it is a global variable. I thought the file buffer variable must available for the time a file is opened and can be discarded after the file has been closed.

True of course. I tried to paint a general case.

If your filehandling is within one procedure it can be on the stack. If that filehandling is within a class, the buffer can be a member of a class etc.

But in neither of these cases it is in the binary.

Reply by email

Jonas Maebe
to Jonas Maebe: You can also allocate it on the heap. Jonas
Jonas Maebe wrote 17 lines
On 22 Jul 2008, at 06:29, leledumbo wrote: > Peter Vreman wrote: >> >> http://www.freepascal.org/docs-html/rtl/system/settextbuf.html >> http://www.freepascal.org/docs-html/rtl/system/settextbuf.html >> > Oh, yeah! I forgot to mention this. But declaring the buffer will > eat spaces > ,for instance: > ... > var > Buf: array [0..65535] of Byte; > ... > will add 64k to the executable because it's allocated on the stack. You can also allocate it on the heap.

But that won't help you in this case, because settextbuf does not change the flushing behaviour when writing to the screen. For that, you have to follow Tomas' advice.

Jonas

Reply by email

leledumbo
to Jonas Maebe
Jonas Maebe-2 wrote 5 lines
But that won't help you in this case, because settextbuf does not change the flushing behaviour when writing to the screen. For that, you have to follow Tomas' advice.

Done, but I still demand it to be in System unit. That way, no additional unit is needed. Does Delphi declare TextRec and FileRec anyway?

View this message in context: http://www.nabble.com/Getting-fast-output-tp18562328p18605192.html Sent from the Free Pascal - General mailing list .

Reply by email