|
Heh[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Vista B. x64 SP 1 Intel Quad 2.4, 2 GB RAM, VS 2008
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
I'm not sure what you're expecting here.
First, if you were running tests in the debugger, forgetaboutit.
Second, comparing times for two sets of loops isn't going to work.
Try putting the loop with the new/delete combined below the other
two loops and you'll see what I mean. There's alot going on with
the heap there, making the results...well, there's no comparison.
Third, comparing native to CLR build...the MSIL is better optimized
than the debug native code (assuming that's what you were comparing to).
Again, no comparison.
I would guess, if you figure out the right combination of optimization switches,
you MAY be able to make the native version a TINY bit faster than the managed
version...maybe...
Lastly, don't believe people that say managed code is slower
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: I'm not sure what you're expecting here.
Not sure what to expect, but definately not this (sounds good).
Mark Salsbery wrote: First, if you were running tests in the debugger, forgetaboutit.
Hey, I'm not an urgent-codes-plz-gimme-guy and I do not do tests in a debugger!!
Mark Salsbery wrote: Second, comparing times for two sets of loops isn't going to work.
That was secondary tests. In fact, the first one was important to me (ok, not important. All this talk is neither interesting nor important, but I must figure the thing out).
Mark Salsbery wrote: the MSIL is better optimized
What could be optimized in such a simple code?
Mark Salsbery wrote: Lastly, don't believe people that say managed code is slower
Lucky and happy you. The problem is that if you believe something (God, Holy Grail, etc.) you likely believe people as well. Oh sorry I'm getting too soap-boxy.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: Not sure what to expect, but definately not this
Definitely didn't expect what?
gajatko wrote: Lucky and happy you.
I have no idea what you mean by that. I didn't state anything about me.
gajatko wrote: The problem is that if you believe something (God, Holy Grail, etc.) you likely believe people as well.
Not sure what that means either. Just because I believe
I'll have another beer doesn't mean I believe people.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It looks like I reached a maximum humour abstraction level last night. Do not take that serious please.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
No problem
Cheers
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Lastly, don't believe people that say managed code is slower
Actually...this is exactly what we're finding.
Real world problem:
- MFC application, 1 EXE and 5 DLL's. The DLL's do all the computations and are highly optimized C++ code which have been validated for correctness and operation many times in the past decade. And we have spent many late nights finding performance gains - the code is good. The front-end is GUI. We have MFC, STL, ATL technologies incorporated, plus a lot of hand-written code - because STL was too slow. The DLL's implement linear algebra, various geometry calculations, and 1st-order PDE's. There are also simple array/table look-ups. The project is 300,000+ lines code.
- we also use ZLIB, GDAL/OGR, CGAL but they aren't used in these tests
Test results:
- baseline is current release build, test case taks 190seconds.
- simply turn on the /clr switch on as many files as possible (following the bouncing ball, trying to do it right) and performance drops to 345 seconds (not all could run managed because of MFC)
- retest native release build, it stays the same
- concerned we are doing too many native/managed swaps to translate 1 DLL to entirely a C++/CLI classlib, performance drops to 355 seconds. Confused so try it again, 361 seconds
- try NGEN on the classlib, performance becomes 349 seconds
- try NGEN on the entire project, performance becomes 476 seconds!
- back out of changes, start over with the native release build, back around 188 seconds
- incorporate the classlib and do MINIMUM required to get things to link back together (to use native as much as possible) and performance is around 244 seconds
All other test cases yield similar results.
We WANT to move to .Net (to clean up the code, make it easier to maintain and read, etc.), but we need a migratory path where we don't have to rewrite the entire front end out of MFC right away. But these performance #'s just suck. We can't ask the client to live with such poor performance during migration in hopes it will improve when it's all done and running strictly in managed. We have experience with C# in another project but are new in the C++/CLI world.
I'd happily discuss this online or offline but 'til then I can't agree with your comment at all Mark!
--Rob
|
|
|
|
|
|
|
Rob Bryce wrote: native->managed->native
Managed/native interop is certainly the biggest performance killer.
Those percentages still seem high though (you're not testing in the debugger, right? ),
although I don't use COM (besides interfaces to things like DirectX, DirectShow, etc) so I
don't know what that adds to the mix.
To get numbers that high, I figure you must be doing some extremely performance
critical stuff across native/managed boundaries. If that's the case, eliminating
that interop is a necessity.
IMO, all managed code gives you is access to the .NET framework. After all, no
self-respecting C++ programmer needs a garbage collector
Given that and what I've read about your situation so far, I would keep everything
compiled native and sprinkle in managed where you need something in the .NET framework.
When you need to cross the native/managed boundary, keep parameter passing to a minimum -
it's that marshaling that's going to hurt performance the most.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Rob Bryce wrote: We WANT to move to .Net (to clean up the code, make it easier to maintain and read, etc.)
Obviously I don't know your project but that statement certainly raises my eyebrow in general. I am not convinced that the C++ language produces less readable or maintainable code. Furthermore, with the additions of the VS2008 C++ Feature pack including TR1 items, it seems even less likely that the language is a barrier to readable, maintainable and flexible design. In fact I believe the exact opposite is true. Features available only in C++ are the reason e.g., like being able to utilize stack rather than always heap, in my mind simplifies readability. PInvoke is another that comes to mind.
In any event, I would certainly not agree to migrate to any managed platform based solely on the belief that the resulting code will be intrinsically more readable, maintainable.
led mike
|
|
|
|
|
Hi led mike,
I believe that my comment needs more clarification.
The motivations (maintainable, readable) are 2-fold and can be better defined as:
1.) I (personally) have never found that the IDL/ATL approach to defining/implementing COM object interfaces is particularly "clean". Nor has the ability to inherit from a COM object been "nice". I should have been more clear that the motivation is to use .Net technology instead of COM technology as a motivation to make it easier to deal with object interfaces intended for re-use outside this project.
2.) I'm (personally) probably one of the few that still enjoy some aspects of MFC for UI programming. But even I have noticed that it's more cost-effective to use more modern languages/features (such as C#) than MFC. And that means entering the managed land, at least in part.
With respect to generic C/C++, these are still my personal language of preference for general day-to-day programming. I agree with you in that the choice of language doesn't necesssarily make code more/less easier to read. However, that language's technologies that we are (forced to?) use (e.g. ATL, MFC) do impact that legibility.
As an aside, I'm doing more management and less programming, and our new staff is being trained (by local universities) to work in managed languages, with little or no exposure to C++. This is a reality that I'm not happy with but have to live with. This may be a problem in the future.
--Rob
|
|
|
|
|
Thanks Rob. Yes your additional information changes the scenario greatly.
Rob Bryce wrote: as a motivation to make it easier to deal with object interfaces intended for re-use outside this project.
I agree that COM is inherently difficult. ATL does improve working with COM greatly but can only go so far. However COM is only necessary to support use of components developed in a different language. This is a heavy restriction and not a requirement for every project. Conversely we can choose the opposite restriction, that being, supporting native C++ components only.
led mike
|
|
|
|
|
led mike wrote: However COM is only necessary to support use of components developed in a different language. This is a heavy restriction and not a requirement for every project.
Yeah, unfortunately, defining the language of choice for projects outside my control, but using the object interfaces that I define, isn't an option - which mean COM or now .Net.
Thanks,
--Rob
|
|
|
|
|
Hi,
Iam using a c++ dll in my .net application.It is running fine on the system where visual studio 2005 is installled.
In the deployment environment we have only framework2.0 installed on the machine.Then Iam getting a pop-up error as
<big><b>"Microsoft visual c++ runtime library
Runtime error
c:\testapp\bin\debug\test.exe
The application has requested the application to terminate in the unusual way
Please contact the application's support team for more information"</b></big>
Please kindly help ASAP
|
|
|
|
|
You are responsible for deploying everything your app needs
to run on a given machine.
Deployment (C++)[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I tried the following as suggested by you:
1. I have installled the redistributable package suggested by you.
after installing i restarted the PC even now also I got the same runtime pop-up error.
2. Then I checked even with the dependency walker for the dll.
I found that there is no miising dll.
3. Then I tried by installing Visual C++ express edition..even then also i got the same pop-up error.
Kindly guide me because Iam new to these concepts...
Kindly help me.....
|
|
|
|
|
There's only a few things I can think of off hand...
Your app needs a .NET runtime that's not installed - maybe at least 2.0 SP1?
You've deployed a debug build of your app or the DLL
Bug in your code or the DLL
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It's not plugged in.
led mike
|
|
|
|
|
That's ok...it will all get cleared up at the new post here[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i have trouble sorting the name in alphabetical order that i have created.
i've tried the sort function but it does not seem to work.
below are my code:
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
#include<algorithm>
using namespace std;
class Person
{
private :
char *personName;
long personphonenumber;
public:
Person(char *name, long phoneNumber);
~Person(); void PrintPerson(); void PrintFile();
friend bool operator<(const Person& left, const Person& right);
};
bool operator<(const Person& left, const Person& right)
{
return left.personName < right.personName;
}
Person::Person(char *name, long phoneNumber){
personName = new char[sizeof(name) + 1];
for(int ii = 0; ii <= (sizeof(name) + 1); ii++){
personName[ii] = name[ii]; personphonenumber = phoneNumber; }
cout << "Creating Employee: " << personName << "\t" << "Phone Number: " << personphonenumber << endl;
}
Person::~Person(){
}
void Person::PrintPerson(){ cout << "----" << endl;
cout << "Name: " << personName << endl;
cout << "Phone Number: " << personphonenumber << endl;
cout << "----" << endl;}void Person::PrintFile(){ fstream oWrite;
oWrite.open("Data.txt", ios::out | ios::app);
oWrite << "Name: " << personName << "\t" << endl;
oWrite << "Phone Number: " << personphonenumber << "\t" << endl;
oWrite << "\n\n"; oWrite.close();}
int main(int argc, char *argv[])
{
char *personName;
char name;
personName = new char[sizeof(name) + 1];
long personphonenumber;
int nInput;
int nNum;
bool cont = true;
Person *personArray; vector<Person> details;
vector<Person>::iterator lpi;
while(cont){
do{
if(cin.fail()){
cin.clear();
while(cin.get() != '\n');
}
cout << "\nPlease select: \nTo create a new data enter '1' \nTo print the data enter '2' \nTo sort the name in alphabetical order enter '3' \nTo quit enter '4'" << endl;
cin >> nInput; }
while(cin.fail() && cout << "\nPlease enter your selection again.. " << endl);
switch(nInput){
case 1:
cout << "Please enter the name: ";
cin >> personName;
cout << endl;
do{
if(cin.fail()){
cin.clear();
while(cin.get() != '\n');
}
cout << "Please enter the phone number: ";
cin >> personphonenumber; cout << endl;
}while(cin.fail() && cout << "\nPlease enter again..");
personArray = new Person(personName, personphonenumber);
details.push_back(*personArray);
break;
case 2:
for(lpi = details.begin(); lpi != details.end(); ++lpi){
lpi -> PrintPerson();
lpi -> PrintFile();
}
break;
case 3:
sort(details.begin(), details.end());
for(lpi = details.begin(); lpi != details.end(); lpi++){
lpi -> PrintPerson();
lpi -> PrintFile();
}
break;
case 4:
cont = false;
break;
default:
cout << "Invalid input try again" << endl;
break;
}
}
return EXIT_SUCCESS;
}
|
|
|
|
|
You posted your question in the wrong forum. The "ATL/WTL/STL" or "Visual C++/MFC" forums are more appropiate.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I do no if there is a limit of number on a form,
I have one form with many controls, When I need to add others, the system create duplicate control on the code and I have many duplicate errors.
That why I need to know if there is a limit.
|
|
|
|
|
There is no actual limit unless you run out of memory. But if you have to operate on a lot controls in a form, I suggest you to:
1) give up a designer and switch to manual coding.
-OR/AND-
2) merge chosen groups of controls to user controls which wouldn't paint themself in design time to avoid flickering and other artifacts while in design mode.
-OR/AND-
3) split a form onto stand-alone functional forms (depends on a kind of a project, not necessarily applicable).
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|