|
Great find!
I've made the changes you'd suggested in my algorithm (to avoid repeatedly summing up columns in overlapping windows), and have been able to shed over 1 second!
The release mode however is still not giving much improvement. The 'optimize' flag is true and 'check for arithmetic overflow' and 'generate debug info' are both set to false. I must mention that the code I had posted is only a small section of my entire procedure. On my end, I'm processing the input image through a series of functions(/filters), each of which update pixel values depending upon the environments and are similar to the extract in my previous post.
Currently, the entire procedure takes an average of ~ 2.4 seconds for a set of 14 test pictures in both Debug and Release modes.
Also, am only working with integers. The input images are 8-bit grayscale images, so these integers are only between 0 and 255.
Thanks...
|
|
|
|
|
So you are now relatively close to your goal...
You say you are working on images. Where does the data come from? Do you convert a Bitmap into a matrix, do your calculations and then recreate the image? If yes you could instead work directly (unsafe) on the bitmap data with the LockBits function from the Bitmap. Its a bit complicated (I don't like pointer handling) but its worth the try.
|
|
|
|
|
I pick the data from the image using the BitmapData object, copy all pixel values to the 2-dimensional array, process this array and finally copy the values back to the memory recreating the image.
I don't have much experience with pointers either , and am avoiding using them extensively 'cause the using the bitmap data directly seems more complicated since the pixels are placed linearly in the memory - whereas I need to analyze 2-dimensional windows (hence the more suitable pixel map).
Besides, I'm not even sure whether using unsafe code and pointers will provide a major breakthrough (although even a not so major breakthrough is acceptable for my case), since most of my processing comprises simple mathematical operations.
|
|
|
|
|
You are probably right. Probably optimization ends here...
Btw: What kind of machine is this running on? Multiprocessor? Hyperthreading? I have have some multithreaded improvements in mind
|
|
|
|
|
Single Processor, Single Thread!
Let's hear about the improvements...
|
|
|
|
|
sarabjs wrote:
Single Processor, Single Thread!
I think in that case threading would be contraproductive...
Sorry but I think I have no further suggestions for improving the performance
|
|
|
|
|
Nein problemo!
You've done great.. Thanks for the help...
Sarab.
|
|
|
|
|
|
No he doesn't. He can't.
Why?
Lets assume you have something like this:
for (int i = 0; i < myArray.Length; i++)
{
}
How can the compiler know what is done within the loop. The loop could probably change the array:
for (int i = 0; i < myArray.Length; i++)
{
myArray = new int[myArray.Length + 10];
}
If the JIT had replaced the condition in the loop with a constant value than the program would not behave correct anymore. This simple example could probably be resolved, but there are more complex examples a compiler can never resolve... so it doesn't even try
I've measured this already as well in debug as in release mode and it can have a real impact on your performance (about 50% if you e.g. just sum up the values of an array).
|
|
|
|
|
|
Hmmm... I've tested some constellations.
As far at it goes to GetLength Im totally right. Caching the length makes it by far faster.
For the normal Length property its a bit more complicated. Brad is true if the arrays is declared locally. If its a field member the cached version will still be a bit faster (about 15%).
Seems to be hard to give some general hints on thic topic. Its mostly like Brad stated:
"The lesson here is more along the lines of measure, measure, measure when you are doing perf work"
|
|
|
|
|
Robert Rohde wrote:
Seems to be hard to give some general hints on thic topic. Its mostly like Brad stated:
"The lesson here is more along the lines of measure, measure, measure when you are doing perf work"
I agree.
David
Never forget: "Stay kul and happy" (I.A.)
David's thoughts / dnhsoftware.org / MyHTMLTidy
|
|
|
|
|
I guess...
Though as far as my requirements are concerned, I don't need to use getLength etc. since the dimensions of the pixel matrix I'm using remain the same throughout.
|
|
|
|
|
I am at the moment building a client/server application using .NET. This is a Win Forms based app and for the communication I thought I would use sockets. But someone just mentioned "why dont you use remoting?". I dont know how skilled this person is and how much experience he has with remoting and/or sockets so I cant really know based on what he made that comment.
The application is nothing out of the ordinary really. The server has a database and the client interacts with the server and inserts, updates, deletes and requests data to/from the server. All clients and the server are all on a local network.
What I really need to know is, how do I know when I have an application that is a good candidate to use remoting for its network communication?
|
|
|
|
|
My take on this :-
Use remoting if client and server are guaranteed to be .NET
If a non-.NET client needs to connect to the server, use sockets
Nish
|
|
|
|
|
I want to distribute an application to people who may or may not have the .NET Framework installed. Currently, I have created a project that includes the application and the .NET Framework. The .NET framework is installed if it is currently not installed. However this leads to a large distribution file (I would like to email my application). As the .NET Framework is only needed to be installed once, any subsequent release containing the .NET Framework would be a waste.
I would prefer to determine if the .NET Framework is installed. If not I would display a popup to tell the user to download the framework from the Microsoft website.
Does anyone know how I could do this?
Thanks
Liam
|
|
|
|
|
You could examine the registry :-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
|
|
|
|
|
What I am struggling with is how I get code to execute to determine if the .NET Framework exists.
The code that I write will need the .NET Framework to run.
|
|
|
|
|
|
|
LiamD wrote:
Does anyone know how I could do this?
Either in C++, or via your MSI generator.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Do you have a link describing how to doing this? I would have thought it a fairly common thing to do.
Thanks,
Liam
|
|
|
|
|
Which one ? Doing it in an MSI is in the help of whatever installer you use, and the C++ code just checks the registry key - here's some code:
bool CRDCInstallerDlg::NeedsDotNet()
{
HKEY key;
bool bRunInstall = true;
ERRORMESSAGE("Checking for .NET", 1);
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\policy\\v1.1", 0, KEY_READ, &key))
{
ERRORMESSAGE("Found registry key", 2);
// Grossly simplified this test because Matt was reporting this was returning true when it should return false.
bRunInstall = false;
BYTE val[10];
DWORD len = 10;
if (ERROR_SUCCESS == ::RegQueryValueEx(key, "4322", NULL, NULL, &val[0], &len))
{
ERRORMESSAGE("Found item 4322", 2);
// Yuck, yuck, yuck. I get an array of bytes out of the registry, but I need a char array for strcmp.
char * pVal = (char*)&val[0];
if (0 == ::strcmp(pVal, "3706-4322"))
{
ERRORMESSAGE("Value is correct", 2);
}
}
::RegCloseKey(key);
}
return bRunInstall;
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You should use Bootstrapper:
http://msdn.microsoft.com/vstudio/downloads/tools/bootstrapper/
|
|
|
|
|
Hi,
I have created a DLL component in Vb.net, i want no other project/person use my component, how to stop outside access .
Advance Thanks
aB
|
|
|
|