![]() |
|
#1
|
|||
|
|||
Writing data efficientlyDear all I am a new user with some problems in programming.
I wrote a simple programme whose goal is to perform a data analysis to find some outliers. Everything work good except when I come to writing the remaining data into a file: it takes really a lot of time (almost 7 minutes). So I tried a smaller programme (which I will post here) just to understand the problem: why it is so slow in printing into a file?? What am I doing wrong?? CPP / C++ / C Code:
The program red a file of 1500000 points and took almost 7 minutes to write them down in a new file (of 50 Mb) Any help is accepted Thank you in advance Gabatwork Last edited by LuciWiz : 28-Sep-2009 at 06:18.
Reason: Please insert your C++ code between [cpp] & [/cpp] tags
|
|||
|
#2
|
|||
|
|||
Re: writing data efficientlyDear all,
It's always me. I have done some trials, compiling the source file with Visual c++ (microsoft). And this time it works much more faster!!! So the problem moves from "what is wrong in my code" to "what is wrong in my compilation procedure??" For the compilation of the program I use gcc. I have done a makefile which is as follows: all : stat.o leggo.o leggo stat.o : stat.c gcc -g -std=c99-Wall -c stat.c leggo.o : leggo.c gcc -g -std=c99 -Wall -c leggo.c leggo : leggo.o stat.o gcc -g -std=c99 -Wall -o leggo.exe stat.o leggo.o Then I just type in the terminal "make all" and everything is done. Thank you in advance. regards Gabatwork |
|
#3
|
|||
|
|||
Re: writing data efficientlyQuote:
CPP / C++ / C Code:
Results on my old Windows XP workstation: Microsoft compiler from Visual C++ 2008 Express Edition (Free download.) Code:
Borland bcc32.exe from Turbo C++ (Free download.) Code:
With the cygwin port of gcc (Open Source---free download.) Code:
With the mingw port of gcc, used in dev-cpp (Open Source---free download.) Code:
Conclusion: File output of the cygwin port of gcc is considerably slower than the "native" compilers from Microsoft and Borland that I have. The mingw port used in dev-cpp uses Microsoft I/O routines and has a run time that is at least the same order of magnitude as the "native" compilers. Bottom line: If it's my decision, I just about never use my Windows machine for "useful" work, but if I just "had to," and if file I/O speed was important, I would (probably) try something other than the cygwin gcc. Regards, Dave Last edited by davekw7x : 28-Sep-2009 at 12:04.
|
|
#4
|
|||
|
|||
Re: writing data efficientlyDear Dave,
Your explanation was perfect! Thank you very much for the reply!!!! I was exactly using cygwin on a windows machine. That was the reason. This forum is great :-) Regards Gabatwork |
|
#5
|
|||
|
|||
Re: writing data efficientlyQuote:
By seeing other people's problems I get a chance look at things from other points of view, and sometimes I can even get (and give) an explanation for some of life's little mysteries. That's why I keep coming back: I always learn something here (always). Regards, Dave |
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Memory leak when nothing is happening... How can I even debug this ? | Algar | MS Visual C++ / MFC Forum | 10 | 19-Nov-2007 08:17 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 14:12 |
| Strange C++ code memory leakage problem | gaoanyu | C++ Forum | 7 | 04-Nov-2005 09:09 |
| [GIM] Data Module - Contact | dsmith | C Programming Language | 2 | 27-Jan-2005 17:30 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 16:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The