|
bigchump, I've posted some suggestions in the c# forum regarding your problem, so I don't want to talk about that here.
What I'm interested in is why you seem to think 64 bit applications should automatically run faster?
Firstly, being 64 bit does not mean faster. a 64 bit app means all your number variables (ints/longs) are twice the size (ints become 64 bits large, longs become 128 bits), so they take up more space. More importantly, all pointers to objects become 64 bits long, so also take up more space. This could mean a potential slow down, as there are lots of hidden issues here related to processing 64 bit pointers.
As I understand it, your app is processing a bunch of data. There is a good chance that on a 64 bit system, this is taking up extra space so can't all fit in memory at one time. This means that the data will be swapped out of memory to the disk. This is a huge time cost. You can investigate this by using a tool such as ProcessExplorer from SysInternals[^]. Try looking at the amount of memory your app is using, and more importantly, the number of page faults that occur during the main processing phase of the app. Compare this to your old c++ version.
The primary reason to switch to 64 bit is that it allows you to address a much larger amount of memory. 32 bit systems are limited to 4GB. 64 bit on the other hand can access 17.2 billion gigabytes. This is of most use on high end database servers. 64 bit does not on it's own give a speed improvement. If anything, switching to 64 bit (using native c++) and not doing anything else is likely to hurt performance.
Finally, real pure 64 bit apps will not run on 32 bit operating systems (not even if you have an 64 bit CPU, the actual operating system must be 64 bit. This means you need windows XP x64 or Vista 64). C# code set to compile to "any cpu" is actually a special case that can change and run as 32 or 64 bit depending on the operating system it is being run on. This is a common misunderstanding. Can you confirm exactly what operating system and compiler settings you are using for your 64 bit app?
Simon
|
|
|
|
|
C# is generally slower than C++ but there are techniques for speeding it up. For example,
1. C# does safety checks that you can skip by running sections in unsafe mode. For example if you're doing an operation on every element of an array, C# will check the array bounds on EVERY array access unless you do it in unsafe mode.
2. When you combine value items and reference items, C# will do "boxing" to convert the value item to a reference item, which is very slow. Avoid this.
3. You can speed up a critical section of your C# by writing a C++ DLL to do it, and calling it from C#.
4. XML serialization in C# is easy, but the SOAP format is insane. It's many times larger than it has to be, and the XML generated is unintelligible. Using a custom format that writes out just the data you need will be faster and more compact.
5. If you're processing bitmaps, look at LockBits to get the bitmap data to work on, which is faster than getpixel/setpixel.
|
|
|
|
|
Hi Alan!
My o/s is Vista 64 Ultimate w/ 8 gigs mem.
I have an identical machine (both are Velocity Micro hotrods) with Vista 32 Ultimate and 4 gigs.
I also have two other machines with XP home.
To load and display a 22meg file takes at least 17 seconds on the 32 bit puters and only 6.4 seconds on the 64.
So, for my purposes 64 is much faster even though the 32 bit apps are written in C with some assy. and the 64 is written in C#.
I have ported all my apps to 64 bit C# and all except the one in question have performance gains.
Using binary serialization to write classes to disk causes the file to become 16x larger than it should be.
I THINK YOU SOLVED MY PROBLEM: write a c++ dll to do file reads/writes.
I've never written a dll so I'm sure I'll have some fun with that.
I could use some tips on writing and calling a c++ dll from a C# program.
Thanx again Alan!
I would have never figured out the problem on my own.
|
|
|
|
|
To create a C++ DLL, create a C++ project and choose Win32 Project as the type (Microsoft probably decided a type named "DLL" would make it too easy), click Next, and select DLL as the application type.
Put the following attribute before your C++ functions so they can be seen from C#:
__declspec(dllexport)
To call a function in a C++ DLL from C#, first declare it like this:
[DllImport("User32.dll")]
public extern static int GetScrollInfo( IntPtr hWnd, int fnBar, IntPtr lpsi );
There's lots of info on the web on doing this. Good luck.
|
|
|
|
|
Hi Alan!
Let me thank you again.
The only question I have left is about this Win32 thing.
Does that mean my dll will run @32 bits (or does it even matter)?
thanx
bigchump
|
|
|
|
|
It means it's a standard Windows application, as opposed to MFC or .NET. I've never tried to run one on a 64-bit platform, but it seems like it would have to work to maintain backward compatibility.
|
|
|
|
|
when i spy the dictionary
why some file create,delete,rename or resize,etc couldn't be spy
and when file update quickly it will miss some of them
this is the code from a filespy demo
static void Action(CSpyDlg* dlg)
{
USES_CONVERSION;
HANDLE hDir = CreateFile( CString("d:"),
FILE_LIST_DIRECTORY,
FILE_SHARE_READ|FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED,
NULL
);
FILE_NOTIFY_INFORMATION Buffer[1024];
DWORD BytesReturned;
while(ReadDirectoryChangesW(
hDir,
&Buffer,
sizeof(Buffer),
TRUE,
FILE_NOTIFY_CHANGE_SECURITY|
FILE_NOTIFY_CHANGE_CREATION|
FILE_NOTIFY_CHANGE_LAST_ACCESS|
FILE_NOTIFY_CHANGE_LAST_WRITE|
FILE_NOTIFY_CHANGE_SIZE|
FILE_NOTIFY_CHANGE_ATTRIBUTES|
FILE_NOTIFY_CHANGE_DIR_NAME|
FILE_NOTIFY_CHANGE_FILE_NAME,
&BytesReturned,
NULL,
NULL
))
{
CTime tm = CTime::GetCurrentTime();
CString helper_txt;
switch(Buffer[0].Action)
{
case FILE_ACTION_ADDED: helper_txt = "The file was added to the directory"; break;
case FILE_ACTION_REMOVED: helper_txt = "The file was removed from the directory"; break;
case FILE_ACTION_MODIFIED: helper_txt = "The file was modified. This can be a change in the time stamp or attributes."; break;
case FILE_ACTION_RENAMED_OLD_NAME: helper_txt = "The file was renamed and this is the old name."; break;
case FILE_ACTION_RENAMED_NEW_NAME: helper_txt = "The file was renamed and this is the new name."; break;
}
int i=0;
do
{
m_Sec.Lock();
int item = dlg->m_list.InsertItem(dlg->m_list.GetItemCount(), CString(Buffer[i].FileName).Left(Buffer[i].FileNameLength / 2) + " - " + helper_txt );
dlg->m_list.SetItemText(item, 1, tm.Format("%Y/%m/%d/ - %H:%M:%S"));
i++;
m_Sec.Unlock();
}
while (!Buffer[i].NextEntryOffset);
}
}
|
|
|
|
|
|
you're right
this function dosen't work on NTFS volume
when i tried on FAT32 volume it works well
thank you
|
|
|
|
|
i know Change Journal now
but if i wanna it works on NTFS how should i do
still
|
|
|
|
|
|
the demo got some error
error C2065: 'USN_JOURNAL_DATA' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'ujd'
error C2065: 'ujd' : undeclared identifier
error C2065: 'FSCTL_QUERY_USN_JOURNAL' : undeclared identifier
error C2228: left of '.UsnJournalID' must have class/struct/union type
error C2228: left of '.FirstUsn' must have class/struct/union type
error C2228: left of '.NextUsn' must have class/struct/union type
error C2228: left of '.LowestValidUsn' must have class/struct/union type
error C2228: left of '.MaxUsn' must have class/struct/union type
error C2228: left of '.MaximumSize' must have class/struct/union type
error C2228: left of '.AllocationDelta' must have class/struct/union type
error C2228: left of '.FirstUsn' must have class/struct/union type
error C2039: 'UsnJournalID' : is not a member of 'READ_USN_JOURNAL_DATA'
c:\program files\microsoft visual studio\vc98\include\winioctl.h(1873) : see declaration of 'READ_USN_JOURNAL_DATA'
error C2228: left of '.UsnJournalID' must have class/struct/union type
error C2039: 'FileNameOffset' : is not a member of 'USN_RECORD'
c:\program files\microsoft visual studio\vc98\include\winioctl.h(1895) : see declaration of 'USN_RECORD'
is there some header file not included??
|
|
|
|
|
You need to install latest platform SDK or if you have the SDK installed change move latest SDK "include path" to top here -> Tools->Options->Directories. I had similar errors!
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
where i can get latest platform SDK
my ide is VC6.0
i am a Chinese so sometimes i can't quite understand correctly
Thanks a lot
|
|
|
|
|
Hi,
i want to open a MDI-Application with more then 1 (2, 4, 6) childviews at startup (like Photoshop)?
Could you explaim me how i can manage this?
I searched at Code-Project but i couldnt't find any sample featuring this ;(
...many thanks
Croc
|
|
|
|
|
2 ways:
Different views attached to the same document
or
Using SplitterViews
There should be examples for that
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi Nelek,
thanx for your quick help!
Hmmm i think i will prefer Splitters, do you think splitters are the better (cleaner) way?
Best regards
Crocodile Buck
|
|
|
|
|
Maybe for 2 or 3 views, but you memtioned 6 in your original post. That's a lot of different views to visually take in all at once, regardless of whether they are splitters or cascading MDI children. Do you really need that many?
Judy
|
|
|
|
|
hi, what is the interface or function to access the taskbar icons?...
|
|
|
|
|
Splitters are good if you don't have many views or if that views are not going to be moved or something like that. If you want to have "free" movement views, to make them visible or invisible depending on menu "view" and so on... it will be better to have more than one view with different childframes, it will give you more freedom to manage them.
It is not optimized (it was my first try, but it works) but you can have a look to this message[^] to open more than one view with only one document, and to this one[^] to manage how to close them priorizing the "main window".
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi,
hmmm i think you all are right, and so i do not need free movement in the actual project and i only need 4 Views i will take splitters!
Many Thanx for your help
&
Best regards
Crocodile Buck
|
|
|
|
|
You are wellcome
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I think better to USE cascading MDI childs to achive photoshop like UI.
-@SuDhIrKuMaR@-
|
|
|
|
|
Hi guys,
does someone know a good freeware tool to generate
UML diagrams making a reverse operation from an existing
Microsoft Visual C++ project ?
Thanks a lot !!
|
|
|
|
|
Rational Rose.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|