> And as Jochen well said, unfortunately this doesn't solve the problems of
current projects...
Any chances of a service pack to fix such issue on 2003 or it's a big
change and will only be available on whidbey?
Sure. I think I can give you a workaround for it in everett.
From your code
#include <time.h>
#include <stdio.h>
/*******Note the pragma unmanaged *******/
#pragma unmanaged
class MyTest1
{
private:
int s_i;
virtual void Test1(int i)
{
s_i += i;
}
public:
void MakeTest()
{
clock_t start, finish;
double duration;
start = clock();
for(int i = 0; i< 10000000; i++)
{
Test1(i);
}
//EndTimeMeasure();
finish = clock();
duration = (double)(finish - start) / (CLOCKS_PER_SEC);
printf( "%2.1f seconds\n", duration );
}
};
int main()
{
MyTest1 obj;
obj.MakeTest();
}
When you compiled your native class with /clr, it causes what is called
double thunking. A call is made from a managed call site to a mangaged
function definition via a native vtable.
Yes, that is right. The vtable is native in this case so there is
performance penalty when you make a transition from managed - native and
native - managed. When I applied #pragma unmanaged over the function
definition, I reduce the thunking from native to managed and thus saved the
performance penalty. On my everett compiler this code took .4 seconds vs
13.5 seconds if I dont use #pragma unmanaged.
Please let me know if this fixes your problem.
Thanks, Kapil
"Gustavo L. Fabro" <gu************************@hotmail.com> wrote in message
news:35*************@individual.net...
Thanks for your reply. I have verified that this is an issue with the
Everett
compiler but this is fixed in beta1 whidbey. You can download beta1 from
msdn.microsoft.com/visualc.
Thanks,
Kapil
Thanks for the comments. I've downloaded whidbey beta 1 (Visual C++ 2005
Express Edition Beta) and run the same tests. After a few teaks to compile
the test properly, things indeed worked much better:
Timings:
Visual C++ 2005 Beta 1
----------------------------
With /CLR : 495
Without /CLR: 382
Visual C++ .NET 2003
----------------------------
With /CLR: 18879
Without /CLR: 151
Borland Builder 5.0 (for comparison)
----------------------------
Builder: 420
Any clues as to when will the final version of VS 2005 be available?
And as Jochen well said, unfortunately this doesn't solve the problems of
current projects...
Any chances of a service pack to fix such issue on 2003 or it's a big
change and will only be available on whidbey?
Thanks
Gustavo Fabro
gu***********************@hotmail.com