|
I'm writting an application that does several processing steps on a file, like encription, compression, checksum calculation, etc, and writes the result to another file. And this is to be done with lots of files of different sizes.
I'ld like to know if, in terms of performance, it would be better to use the CRT, the Win32 API for File I/O or the Win32API for File Mapping or another that I'm not aware .
Also I'ld like to know if using concurrent threads to write several files to disk at the same time would be a good option or would it cause havoc in the file system.
Thank you
Artur Jales Moreira
|
|
|
|
|
MC crt usually uses Win32 APIs anyway.
File mapping is useful because you work with memory and write to the file once.
If you can divide your application tasks to write several files at once, it is a great idea( it is probably one of the most efficient use of MT).
|
|
|
|
|
Win32 API would be the fastest because all the other methods use Win32 API but as I say that it does not make a lot of difference because the hard drive is much slower than memory or the CPU so a few more cpu instructions will not make a difference when the CPU executes billions of instructions a second.
jales wrote:
Also I'ld like to know if using concurrent threads to write several files to disk at the same time would be a good option or would it cause havoc in the file system.
If the OS did not cache the data this would be very bad for performance because this will cause the disk to thrash, however with cache some of this will be masked by the system. I do not recommend this however.
John
|
|
|
|
|
jales wrote:
I'ld like to know if using concurrent threads to write several files to disk at the same time would be a good option or would it cause havoc in the file system
Definitely : do not do that.
~RaGE();
|
|
|
|
|
And why not? There is no problem having several threads writing to different files the same time.
What will be a problem is having several threads writing to the SAME file at the same time.
Magnus
|
|
|
|
|
Won't that add to disk and disk cache fragmentation? My principal concern is speed, but I don't want to have to use defrag in the end
Thank you
Artur Jales Moreira
|
|
|
|
|
If you add small chunks to the file and either closes the file or empty the cache and then adds more data and repeat. Then you will have fragmentation.
If you really is concerned you can always reserve a filesize, but I dont think it will be necessary if you have NTFS. And the windows file cache will also minimize the number of writes that actually goes to the HD.
Magnus
|
|
|
|
|
Magnus is correct. There's nothing wrong with multiple threads writing to multiple files at the same time.
Multiple threads writing to the same file is a really bad idea. It will work if you do it properly, but really, really, really, dangerous.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'm working on a project which is Single Document-MFC.
I'm learning database(ODBC) programing with visual c++ 6.0.
I want enter a numaric value into an EditBox.
Then this value should be stored in *.mdb table as long integer.
I chose catagory as value and variable type long from class wizard.
But I could not write any code for it.
please,help me !
|
|
|
|
|
Add a handler for IDOK using the class wizard. In your OnOk() member function add code to store your long value to the database using ODBC. I believe you have to add your code after the call to the base class.
John
|
|
|
|
|
Well, im not sure its refered to as dynamic text, but here's what i want to do.
Suppose i have a word in a text file. I input that word into a string, call it str_word. What i'd like to do is display that word in my dialog box. Just like i would a static test, but instead of creating the static text before runtime, it outputs the str_word.
ie, in a console application, i'd do something like...
cout << "You are now editing " << str_word << endl;
thats essentially what i'd like to do, but this is in a MFC dialog box, not in an edit control, listbox or anything, its just like static text.
*.*
|
|
|
|
|
Add a static text to your dialog (put anything you want in it, you can put an empty string) and rename it to another ID (say IDC_MYTEXT). Be sure the static text window is long enough to contain all the desired text.
Then read your string and use this:
GetDlgItem(IDC_MYTEXT)->SetWindowText(str_word);
|
|
|
|
|
thankya!
*.*
|
|
|
|
|
Or even SetDlgItemText( IDC_MYTEXT, str_word ) which is quicker to type, and has less 'noise', IMO.
--
Mike Dimmick
|
|
|
|
|
This is just for my personal knowledge, but ion C++, is tere an easier way to convert a string into an LPCTSTR? Here's how im doing it now, which is quite laborious...
<br />
int ch_num = 0;<br />
string tool_name;<br />
LPCTSTR str_word = "";<br />
channel_gettoolname(ch_num, tool_name);<br />
tool_name += ".";<br />
CString boo;<br />
char bleh[100];<br />
for(int i = 0; i < tool_name.size(); i++)<br />
{<br />
bleh[i] = tool_name[i];<br />
boo += bleh[i];<br />
}<br />
str_word = boo;<br />
GetDlgItem(IDC_ch0edittxt)->SetWindowText(str_word);<br />
where channel_gettoolname(ch_num, tool_name); passes a string, 'tool_name' by reference.
i have to covnert my string into an array of Char, convert the array of Char into a CString, then convert the CString into an LPCTSRT. i tried strcpy() but it kept saying i cant convert a string into a char.
*.*
|
|
|
|
|
|
If you mean a std::string , bear in mind that it isn't a Unicode string, it's an ANSI one. If you're compiling for ANSI, this isn't a problem (since TCHAR == char, for a build where UNICODE isn't defined).
You can access the array of characters in a std::string by calling the c_str() member function.
You should be able to write:
std::string tool_name;
channel_gettoolname( ch_num, tool_name );
tool_name += ".";
SetDlgItemText( IDC_ch0edittxt, tool_name.c_str() ); Hey, where'd my line-spacing go??
--
Mike Dimmick
|
|
|
|
|
thanks
*.*
|
|
|
|
|
How can I do my program work with windows api? for example: when an user click with mouse anywhere out window, windows api will send to my programa this event, or better when I click on button at internet explorer my program have that know about that was did.
|
|
|
|
|
|
Hallo !!!
I Have a Problem:
I have a ListControl and the Horizontal Scroll Bar
should not dissepear when it is no longer needed.
It should only be disabled.
What can I Do ??
Thanx for helping me............
cu
Dirk
cadnt@web.de
schonus
|
|
|
|
|
The default behavior is for it to be removed, thus freeing up a bit more of the control. Why would you want it to stay around?
|
|
|
|
|
It Is a little bit complicated to exlplain, but I use it beside a text editor , which has also a scroll-bar .
This text-editor scroll bar do not disappear, and the
CListCtrl Scroll bar also shold not dissepear!!
So, can you help me??
|
|
|
|
|
i want to add datatime pickup activeXcontorl on the dialg in my dll.
can i do like that, if can, how to realize ?
gucy
|
|
|
|
|
Do you have to use ActiveX or may be you could settle for the common control? If yes use resource editor in VC7(6) and pick it from the Dialog editor's list of available controls.
|
|
|
|