Einzelnen Beitrag anzeigen

shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#11

Re: File IO mit dem Windows-API?

  Alt 9. Jun 2008, 13:55
Zitat von HHick123:
Was ich bei TFileStream etwas schade finde, ist dass es eine "Eigenintelligenz" bezüglich der Größe der tatsächlich gelesenen Häppchen zu haben scheint, ...
TFileStream reicht Read und Write Aufrufe ziemlich direkt an das Betriebssystem durch. (Also TFileStream puffert nicht )
TFileStream.ReadBuffer -> TFileStream.Read -> FileRead() -> ReadFile() Win-API

Wenn man Byteweise liest, wird man trotz des geringen Overheads einen Leistungsverlust merken.
So ungefähr ab 256 Bytes gibt es kaum noch Unterschiede zu grösseren Blockgrössen.
Hier eine Messung:
Code:
write 1048576 blocks ā 1 bytes: 5750 ms
write 524288 blocks ā 2 bytes: 2547 ms
write 262144 blocks ā 4 bytes: 1266 ms
write 131072 blocks ā 8 bytes: 640 ms
write 65536 blocks ā 16 bytes: 313 ms
write 32768 blocks ā 32 bytes: 172 ms
write 16384 blocks ā 64 bytes: 78 ms
write 8192 blocks ā 128 bytes: 31 ms
write 4096 blocks ā 256 bytes: 31 ms
write 2048 blocks ā 512 bytes: 16 ms
write 1024 blocks ā 1024 bytes: 0 ms
write 512 blocks ā 2048 bytes: 0 ms
write 256 blocks ā 4096 bytes: 15 ms
write 128 blocks ā 8192 bytes: 0 ms
write 64 blocks ā 16384 bytes: 0 ms
write 32 blocks ā 32768 bytes: 0 ms
read 1048576 blocks ā 1 bytes: 2813 ms
read 524288 blocks ā 2 bytes: 1437 ms
read 262144 blocks ā 4 bytes: 704 ms
read 131072 blocks ā 8 bytes: 343 ms
read 65536 blocks ā 16 bytes: 188 ms
read 32768 blocks ā 32 bytes: 78 ms
read 16384 blocks ā 64 bytes: 47 ms
read 8192 blocks ā 128 bytes: 31 ms
read 4096 blocks ā 256 bytes: 16 ms
read 2048 blocks ā 512 bytes: 0 ms
read 1024 blocks ā 1024 bytes: 0 ms
read 512 blocks ā 2048 bytes: 15 ms
read 256 blocks ā 4096 bytes: 0 ms
read 128 blocks ā 8192 bytes: 0 ms
read 64 blocks ā 16384 bytes: 0 ms
read 32 blocks ā 32768 bytes: 0 ms
Andreas
  Mit Zitat antworten Zitat