Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-03-2006, 02:01 PM
|
#1
|
|
LQ Newbie
Registered: Aug 2006
Posts: 4
Rep:
|
Slow file writing with 'fwrite' function in C-code...
First of all, I am not sure if this problem comes from the OS or Hardware or even my program.
Anyway, when I execute a simple C-code which is doing some processing and writes the results
into the hard disc, the program takes too much time to finish up the file writing. The file size is about 450MB. I am using 'fwrite' function which is normally working well in elsewhere but in our new computer ( workstation which has 4 CPUs and each is dure core), it shows really slow file writing. It take a couple of minitues to finish up the writing. Sometimes, when I slightly change my code (Definiely, other parts which is not related with this writing module), it is fast ( done within a few secs).
Any one has same problem ? or Any idea will be reall appreciated.
Last edited by scho; 08-03-2006 at 02:13 PM.
|
|
|
|
08-04-2006, 07:06 AM
|
#2
|
|
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Rep:
|
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
|
|
|
08-04-2006, 07:09 AM
|
#3
|
|
Senior Member
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,037
Rep: 
|
are you reading from and writing to a disk? perhaps adding or increasing the buffers of your reading and writing will speed-up the operation.
Last edited by konsolebox; 09-23-2006 at 06:13 AM.
|
|
|
|
08-04-2006, 07:11 AM
|
#4
|
|
Senior Member
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Rep:
|
It is hard to say why, but my suggestion is to run strace on your program. This could give you an idea of what exactly it is doing when it slows down.
|
|
|
|
08-04-2006, 07:13 AM
|
#5
|
|
Senior Member
Registered: Dec 2003
Posts: 3,142
Rep: 
|
Code:
The file size is about 450MB.
There's your answer.
It depends on a lot of things. Without the code and without knowing what the background processes are, where and how you call the fwrite function, we can only guess as to why your code is slow.
|
|
|
|
08-07-2006, 12:42 AM
|
#6
|
|
Member
Registered: Oct 2004
Location: India
Distribution: Redhat
Posts: 88
Rep:
|
Since by changing code in "other parts", you are able to speed up, it could be your "some processing" which is taking up time, may be rightly so too. I think you should post code, without which no one can point the exact problem.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:45 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|