Why is there no difference between buffered and unbuffered file IO?

P

pank7

hi everyone,

I have a program here to test the file IO(actually output) with buffer
turned on and off. What I want to see is that there will be obvious
differece in time. Here I have an input file scales 1.1M, what I did is
just copy it to another output file(ten times). But I don't think I see
any difference. My file system is ext3, with debian
sarge(kernel-2.6.8).
Here is the main part of my program:


The result is here:
Size of the input file: 1128838 bytes.
Buffer size of the file: 4096.
Choose:
1. Unbuffered test.
2. Buffered test.
b
Time begin(buffered): 1134782563 sec 803489 microsec.
Time finish(buffered): 1134782563 sec 852111 microsec.
Time spent on buffered test: 0 sec 48622 microsec.


Size of the input file: 1128838 bytes.
Buffer size of the file: 4096.
Choose:
1. Unbuffered test.
2. Buffered test.
u
Time begin(unbuffered): 1134782571 sec 685364 microsec.
Time finish(unbuffered): 1134782571 sec 732220 microsec.
Time spent on buffered test: 0 sec 48622 microsec.

can anyone help me?

I've also tried to run this program on FreeBSD-5.4, but no diff either
Thanx!!!
pank7.yardbird
 
J

Jack Klein

hi everyone,

I have a program here to test the file IO(actually output) with buffer
turned on and off. What I want to see is that there will be obvious
differece in time. Here I have an input file scales 1.1M, what I did is
just copy it to another output file(ten times). But I don't think I see
any difference. My file system is ext3, with debian
sarge(kernel-2.6.8).
Here is the main part of my program:

[snip code]

The C standard does not specify the relative speed of anything.

There are a large number of factors that can impact the result of a
test like this. These include the compiler, its library
implementation, the operating system, and its configuration, just to
name a few.

The results you obtained are just that, the results you obtained, and
the C language is indifferent as to whether they are what you
expected.

If you want more information, post in a platform specific group like
one of family. This is not a
language issue.
 
P

pank7

Thank you! I appreciate that.

But could you please give me some suggestions on
how to do such a test? What shall I do if I wanna
see the differences?
 
M

Mark McIntyre

Thank you! I appreciate that.

Please read this:
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: said:
But could you please give me some suggestions on
how to do such a test? What shall I do if I wanna
see the differences?

The ways to test this are outside the scope of C, you';d have to ask
in groups specialising in your operating system, compiler and /or
hardware.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top