From: mohangupta13 on 3 May 2010 04:18 Hello all , For this problem i did a lot of searching but didn't get much.... I wanted to know on modern machines ( PC's i mean say X86 one) what is the average number of machine cycles required to read/write a character to IDE disks (say in a log file) ? And for printing a character to stdout ...and also the total overhead of printf() like system calls.?? What i actually want to study is the impact on performance of my program by various printf() calls it makes and the log it writes out to log files ?? Please also refer to some detailed guides on these topics .. Thanks Mohan
From: Ian Collins on 3 May 2010 04:34 On 05/ 3/10 08:18 PM, mohangupta13 wrote: > Hello all , > > For this problem i did a lot of searching but didn't get much.... > > I wanted to know on modern machines ( PC's i mean say X86 one) what is > the average number of machine cycles required to read/write a > character to IDE disks (say in a log file) ? And for printing a > character to stdout ...and also the total overhead of printf() like > system calls.?? Not many, but that's not what takes the time. Most of the time used writing to disk is waiting for the disk to complete the write. > What i actually want to study is the impact on performance of my > program by various printf() calls it makes and the log it writes out > to log files ?? Then you should profile your program. -- Ian Collins
From: Pascal J. Bourguignon on 3 May 2010 11:56 mohangupta13 <mohangupta13(a)gmail.com> writes: > Hello all , > > For this problem i did a lot of searching but didn't get much.... > > I wanted to know on modern machines ( PC's i mean say X86 one) what is > the average number of machine cycles required to read/write a > character to IDE disks (say in a log file) ? And for printing a > character to stdout ...and also the total overhead of printf() like > system calls.?? > > What i actually want to study is the impact on performance of my > program by various printf() calls it makes and the log it writes out > to log files ?? > > Please also refer to some detailed guides on these topics .. You should do two things: 1- understand in a broad way, how the various elements work. (how does a processor work, how does the memory work, how does the hard disk work, how the buses work (to communicate between the components) etc). 2- search for the technical specifications of one or a couple of them. (This is easy, with google, the hardware manufacturers gladly provides their technical specifications on the web). Then you will be able to compute an approximation of the times needed for each operation in each kind of device. For example in the case of a hard disk, you have to understand that there is a disk that is spinning, so you will have to know the rotation speed from the technical specification. The is one (or several) read/write heads that move across the surface of the disk on a radius, and it takes some time to move from one track to the other (get this time from the spec). Then when you need to read a sector from the disk, you can compute the time needed for the head to move to the right track, and for the plate to spin the sector under the read/write head, and the time needed to read the sector into the disk buffer. Then add the time needed to transfer the data over the bus to the next component. -- __Pascal Bourguignon__ http://www.informatimago.com
From: Moi on 3 May 2010 14:34 On Mon, 03 May 2010 01:18:35 -0700, mohangupta13 wrote: > Hello all , > > For this problem i did a lot of searching but didn't get much.... > > I wanted to know on modern machines ( PC's i mean say X86 one) what is > the average number of machine cycles required to read/write a character > to IDE disks (say in a log file) ? And for printing a character to > stdout ...and also the total overhead of printf() like system calls.?? [NB: printf() is not a system call.] Calling a function is relatively expensive, say 10~~100 ticks. In the printf-case, it will have to 1) study the format string, 2) fetch the arguments, 3) format them into a buffer, and 4) finally (*maybe*) write/flush this buffer to a disk; once it is full. The write (or flush) are relatively expensive because they involve a context-switch (to and fro), maybe 1000~~10000 cycles. Plus transferring the buffer from userspace to a systembuffer (but memcpy's are relatively cheap) The actual write is relatively costless, as long as the I/O bus is not saturated, and if you don't wait for it's completion. NOTE: my number of cycles are just guesses. YMMV. > What i actually want to study is the impact on performance of my program > by various printf() calls it makes and the log it writes out to log > files ?? Measure it. My guess is that a standard desktop machine can run a while (fgets(...)) { fputs(...); } -loop at bus speed, and still have cycles left to burn. [You could use fprintf() instead of fputs() to burn some additional cycles... ] HTH, AvK
|
Pages: 1 Prev: ANN: Seed7 Release 2010-05-02 Next: Converting from 0 and 1 to -1 and 1 |