Click here to Skip to main content
15,914,795 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionTimerQueueTimers..A question.. Pin
montiee31-Aug-08 5:53
montiee31-Aug-08 5:53 
AnswerRe: TimerQueueTimers..A question.. Pin
Mark Salsbery31-Aug-08 7:12
Mark Salsbery31-Aug-08 7:12 
QuestionRe: TimerQueueTimers..A question.. [modified] Pin
montiee1-Sep-08 8:39
montiee1-Sep-08 8:39 
QuestionCode efficiency Pin
Evgeni5731-Aug-08 5:26
Evgeni5731-Aug-08 5:26 
AnswerRe: Code efficiency Pin
Robert.C.Cartaino31-Aug-08 7:32
Robert.C.Cartaino31-Aug-08 7:32 
AnswerRe: Code efficiency Pin
Mark Salsbery31-Aug-08 7:35
Mark Salsbery31-Aug-08 7:35 
GeneralRe: Code efficiency Pin
Evgeni5731-Aug-08 22:17
Evgeni5731-Aug-08 22:17 
GeneralRe: Code efficiency Pin
Mark Salsbery1-Sep-08 7:58
Mark Salsbery1-Sep-08 7:58 
Evgeni57 wrote:
It will increase the number of the disk's accesses so I don't think it will be more efficient.


No, it won't.

If you're using the fopen/fseek/etc. family of I/O functions, then
data is being read in 4K (by defult) chunks.

Evgeni57 wrote:
If I read any time 8192 bytes - size of disk's cluster, that I'm working with, then some records will be missed and seeking/rewinding or using my own buffering is essential.


Assuming doing your own buffering (which currently is an
inefficient solution) you would parse records from your buffer until
there's not a complete record left. Then you shift the remaining contents
of the buffer to the beginning of the buffer and read more bytes from
disk. There's no rewinding or seeking backward required, and to do so
would be inefficient - you'd be reading the same data multiple times.
Given what you've described as your file spec, this is completely unnecessary.

If you intend to do your own buffering, then you should use UNBUFFERED I/O,
not fopen/fread/fseek/etc.

You've got a good file format for sequential reading, which is always the fastest.
Why are you trying to complicate that?

Do some benchmarks - I would bet simply looping using fread to read a record length
followed by an fread to read the record data will be more efficient than anything
you come up with involving random access (seeking backward).

You can then tune the default buffer size (see setvbuf()) to something more appropriate
for your typical record size. For example, reading 20 byte records with the default 4K
buffer is pretty efficient. Reading 8K size records would do better with a larger buffer,
maybe 32K.

Mark

Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

Questionc++ function help Pin
anjoz96631-Aug-08 4:07
anjoz96631-Aug-08 4:07 
AnswerRe: c++ function help Pin
Cedric Moonen31-Aug-08 5:42
Cedric Moonen31-Aug-08 5:42 
QuestionSTL exception Pin
followait30-Aug-08 23:04
followait30-Aug-08 23:04 
AnswerRe: STL exception Pin
Mark Salsbery31-Aug-08 7:47
Mark Salsbery31-Aug-08 7:47 
GeneralRe: STL exception Pin
followait31-Aug-08 18:00
followait31-Aug-08 18:00 
Questionifstream question Pin
followait30-Aug-08 16:40
followait30-Aug-08 16:40 
QuestionInvert ARGB [modified] Pin
bob1697230-Aug-08 7:12
bob1697230-Aug-08 7:12 
AnswerRe: Invert ARGB Pin
Mark Salsbery30-Aug-08 8:04
Mark Salsbery30-Aug-08 8:04 
GeneralRe: Invert ARGB Pin
bob1697230-Aug-08 11:52
bob1697230-Aug-08 11:52 
GeneralRe: Invert ARGB Pin
Mark Salsbery30-Aug-08 11:58
Mark Salsbery30-Aug-08 11:58 
QuestionLooking for C++ CWnd equivalent of C#'s Control.Invoke, Control.IsInvokeRequired Pin
Ohad Maishar30-Aug-08 6:13
Ohad Maishar30-Aug-08 6:13 
AnswerRe: Looking for C++ CWnd equivalent of C#'s Control.Invoke, Control.IsInvokeRequired Pin
Mark Salsbery30-Aug-08 6:46
Mark Salsbery30-Aug-08 6:46 
Questionopening network connections Pin
VCProgrammer30-Aug-08 1:50
VCProgrammer30-Aug-08 1:50 
AnswerRe: opening network connections Pin
Dr. Emmett Brown30-Aug-08 3:34
Dr. Emmett Brown30-Aug-08 3:34 
QuestionRe: opening network connections Pin
David Crow30-Aug-08 4:30
David Crow30-Aug-08 4:30 
AnswerRe: opening network connections Pin
Mark Salsbery30-Aug-08 6:41
Mark Salsbery30-Aug-08 6:41 
GeneralRe: opening network connections Pin
VCProgrammer31-Aug-08 20:16
VCProgrammer31-Aug-08 20:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.